CF773B.Dynamic Problem Scoring
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.

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 109 + 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.
瓦西娅和佩佳参加一场 Codeforces 比赛。该比赛持续两小时,共包含五道题目。
本场采用动态题目评分机制(dynamic problem scoring)。如果你此前从未参加过采用动态评分机制的 Codeforces 比赛,那么其规则如下:每道题目的最高分值取决于“解出该题的参赛者人数”与“整场比赛总参赛人数”之比。所有至少提交过一次的选手均视为参与了本场比赛。

请注意区间端点的取值方式。例如,若共有 40 人参赛,其中 10 人解出了某道题目,则该题的解出比例为 1/4,对应最高分值为 1500 分。
若某题最高分值为 x,则从比赛开始至该选手对该题首次正确提交所经过的每整分钟,该选手将被扣减 x/250 分。例如,若某题最高分值为 2000 分,而某选手在比赛开始后第 40 分钟提交了正确解法,则该选手此题得分为 2000⋅(1−40/250)=1680 分。
本场共有 n 名参赛者,其中包括瓦西娅和佩佳。对每位参赛者及每道题目,已知其从比赛开始到向该题提交答案所经过的分钟数;也可能该参赛者未向该题提交过任何答案。
距离比赛结束仅剩两秒时,所有参赛者的提交均已通过预测试(pretests),且尚未发生任何 Hack 行为。瓦西娅认为:剩余两秒内不会再有任何新的提交或 Hack 尝试,且所有已提交的答案均将通过系统测试(system testing)。
不幸的是,瓦西娅是一名作弊者。他为此轮比赛额外注册了 109+7 个新账号。现在,瓦西娅可利用这些新账号,任意提交自己已准备好的任一题解(即他本人已正确解决的题目),从而改变各题目的最高分值;他也可以向任意题目提交任意错误解法。注意:瓦西娅不得向他自己尚未解出的题目提交正确解法。
瓦西娅的目标是在本轮比赛中严格超过佩佳的总得分。他已编写好脚本,可在极短时间内(毫秒级)将任意解法混淆并从任意新账号提交至系统。然而,瓦西娅不想让作弊行为过于明显,因此他希望在达成目标的前提下,使用尽可能少的新账号进行提交。
请找出瓦西娅为击败佩佳所需使用的最少新账号数量(假设其上述判断全部成立);若无法达成目标,请报告这一点。
输入格式
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.
第一行包含一个整数 n(2≤n≤120)—— 参赛人数,包括瓦西里(Vasya)和佩佳(Petya)。
接下来的 n 行中,每行包含五个整数 ai,1, ai,2, …, ai,5(−1≤ai,j≤119),表示第 i 位参赛者提交第 j 道题所用的时间(单位:分钟),即从比赛开始到其提交该题的时间;若第 i 位参赛者未解决第 j 道题,则对应值为 −1。
保证每位参赛者至少有一次成功提交。
瓦西里是第 1 号参赛者,佩佳是第 2 号参赛者,其余参赛者的顺序任意。
输出格式
Output a single integer — the number of new accounts Vasya needs to beat Petya, or -1 if Vasya can't achieve his goal.
输出一个整数——Vasya 为击败 Petya 所需创建的新账号数量;若 Vasya 无法实现其目标,则输出 −1。
输入输出样例
输入#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
说明/提示
In the first example, Vasya's optimal strategy is to submit the solutions to the last three problems from two new accounts. In this case the first two problems will have the maximum point value of 1000, while the last three problems will have the maximum point value of 500. Vasya's score will be equal to 980 + 940 + 420 + 360 + 270 = 2970 points, while Petya will score just 800 + 820 + 420 + 440 + 470 = 2950 points.
In the second example, Vasya has to make a single unsuccessful submission to any problem from two new accounts, and a single successful submission to the first problem from the third new account. In this case, the maximum point values of the problems will be equal to 500, 1500, 1000, 1500, 3000. Vasya will score 2370 points, while Petya will score just 2294 points.
In the third example, Vasya can achieve his goal by submitting the solutions to the first four problems from 27 new accounts. The maximum point values of the problems will be equal to 500, 500, 500, 500, 2000. Thanks to the high cost of the fifth problem, Vasya will manage to beat Petya who solved the first four problems very quickly, but couldn't solve the fifth one.
在第一个例子中,瓦西娅的最优策略是使用两个新账号提交最后三道题的解答。此时,前两道题的最高分值为 1000,而后三道题的最高分值为 500。瓦西娅的得分为 980+940+420+360+270=2970 分,而佩佳仅得 800+820+420+440+470=2950 分。
在第二个例子中,瓦西娅需使用两个新账号各自对任意一道题进行一次失败提交,并使用第三个新账号对第一道题进行一次成功提交。此时,各题的最高分值分别为 500、1500、1000、1500、3000。瓦西娅得分为 2370 分,而佩佳仅得 2294 分。
在第三个例子中,瓦西娅可通过使用 27 个新账号分别提交前四道题的解答来实现目标。此时,各题的最高分值分别为 500、500、500、500、2000。得益于第五道题高昂的分值,瓦西娅得以击败佩佳——佩佳虽迅速解出了前四道题,却未能解出第五道题。
输入解题思路,AI测评打分。不知道怎么写?