Ice Cream

시간 제한2초메모리 제한512 MB

요약
최대 n개의 스쿱과 k가지 맛, 겹칠 때의 추가 점수, 스쿱당 비용이 주어질 때 총맛 나누기 총비용의 최댓값을 구한다.
난이도

어려움10점 중 8점

유형
동적 계획법, 이분 탐색, 그래프, 수학
정답자
아직 제출이 없습니다

문제

Ice cream is a difficult topic. You are at the ice cream store and have some trouble deciding how you want your ice cream. How many scoops? What flavours? In what order? The only way to ensure that you are making the right decisions is to approach the problem systematically. Therefore, you examine each of the kk flavours and estimate that the tastiness of a scoop of the iith flavour is t_it\_i. However, you are aware that some flavours complement each other, resulting in a tastiness greater than the sum of the individual flavours, whereas others just do not go very well together. Therefore, you have estimated the additional tastiness experienced whenever a scoop of one flavour is directly on top of a scoop of another, and what happens when you put two scoops of the same flavour on top of each other. The additional tastiness experienced whenever flavour ii is on top of flavour jj is u_i,ju\_{i,j}. Of course, you would like to maximize the total tastiness of your ice cream, but there are two problems.

Firstly, your stomach is, regrettably, finite. Therefore, you do not want to order more that nn scoops. You may order fewer scoops, if this is better.

Secondly, ice cream isn't free. Each scoop costs aa gold coins, and the cone costs bb gold coins (regardless of the number of scoops of ice cream you buy).

You would like to find the maximum possible tastiness per gold coin ratio. The store has an infinite amount of each flavour.

입력

The first line of input consists of the integers nn (1≤n≤2⋅1091 \leq n \leq 2 \cdot 10^9), kk (1≤k≤1001 \leq k \leq 100), aa and bb (1≤a,b≤2001 \leq a,b \leq 200).

The following line consists of kk integers t_it\_i (−200≤t_i≤200-200 \leq t\_i \leq 200), the tastiness of each of the flavours.

The following kk lines each contain kk integers. The jjth number on the iith line is the additional tastiness u_i,ju\_{i,j} (−200≤u_i,j≤200-200 \leq u\_{i,j} \leq 200).

출력

If it is impossible to get an ice cream with positive tastiness, display 00.

Otherwise, display the largest possible value of the quotient of the tastiness and the cost of an ice cream.

Your answer will accepted if it is within a relative or absolute error of at most 10−610^{-6} of the correct answer.

예제2

  1. 예제 1

    입력
    20 3 5 5
    0 0 0
    0 -10 0
    30 0 0
    0 0 0
    
    예상 출력
    2
    
  2. 예제 2

    입력
    10 1 8 20
    5
    0
    
    예상 출력
    0.500000000