304019: CF773B. Dynamic Problem Scoring
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Dynamic Problem Scoring
题目描述
Vasya and Petya take part in a Codeforces round. The round lasts for two hours and contains five problems. For this round the dynamic problem scoring is used. If you were lucky not to participate in any Codeforces round with dynamic problem scoring, here is what it means. The maximum point value of the problem depends on the ratio of the number of participants who solved the problem to the total number of round participants. Everyone who made at least one submission is considered to be participating in the round. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF773B/a0f85cbd533a46bf976e07f7a2f9ea90ac93ff77.png) Pay attention to the range bounds. For example, if 40 people are taking part in the round, and 10 of them solve a particular problem, then the solvers fraction is equal to $ 1/4 $ , and the problem's maximum point value is equal to 1500. If the problem's maximum point value is equal to $ x $ , then for each whole minute passed from the beginning of the contest to the moment of the participant's correct submission, the participant loses $ x/250 $ points. For example, if the problem's maximum point value is 2000, and the participant submits a correct solution to it 40 minutes into the round, this participant will be awarded with $ 2000·(1-40/250)=1680 $ points for this problem. There are $ n $ participants in the round, including Vasya and Petya. For each participant and each problem, the number of minutes which passed between the beginning of the contest and the submission of this participant to this problem is known. It's also possible that this participant made no submissions to this problem. With two seconds until the end of the round, all participants' submissions have passed pretests, and not a single hack attempt has been made. Vasya believes that no more submissions or hack attempts will be made in the remaining two seconds, and every submission will pass the system testing. Unfortunately, Vasya is a cheater. He has registered $ 10^{9}+7 $ new accounts for the round. Now Vasya can submit any of his solutions from these new accounts in order to change the maximum point values of the problems. Vasya can also submit any wrong solutions to any problems. Note that Vasya can not submit correct solutions to the problems he hasn't solved. Vasya seeks to score strictly more points than Petya in the current round. Vasya has already prepared the scripts which allow to obfuscate his solutions and submit them into the system from any of the new accounts in just fractions of seconds. However, Vasya doesn't want to make his cheating too obvious, so he wants to achieve his goal while making submissions from the smallest possible number of new accounts. Find the smallest number of new accounts Vasya needs in order to beat Petya (provided that Vasya's assumptions are correct), or report that Vasya can't achieve his goal.输入输出格式
输入格式
The first line contains a single integer $ n $ ( $ 2<=n<=120 $ ) — the number of round participants, including Vasya and Petya. Each of the next $ n $ lines contains five integers $ a_{i,1},a_{i,2}...,a_{i,5} $ ( $ -1<=a_{i,j}<=119 $ ) — the number of minutes passed between the beginning of the round and the submission of problem $ j $ by participant $ i $ , or -1 if participant $ i $ hasn't solved problem $ j $ . It is guaranteed that each participant has made at least one successful submission. Vasya is listed as participant number 1, Petya is listed as participant number 2, all the other participants are listed in no particular order.
输出格式
Output a single integer — the number of new accounts Vasya needs to beat Petya, or -1 if Vasya can't achieve his goal.
输入输出样例
输入样例 #1
2
5 15 40 70 115
50 45 40 30 15
输出样例 #1
2
输入样例 #2
3
55 80 10 -1 -1
15 -1 79 60 -1
42 -1 13 -1 -1
输出样例 #2
3
输入样例 #3
5
119 119 119 119 119
0 0 0 0 -1
20 65 12 73 77
78 112 22 23 11
1 78 60 111 62
输出样例 #3
27
输入样例 #4
4
-1 20 40 77 119
30 10 73 50 107
21 29 -1 64 98
117 65 -1 -1 -1
输出样例 #4
-1