博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #412 Div. 2 补题 D. Dynamic Problem Scoring
阅读量:6194 次
发布时间:2019-06-21

本文共 6017 字,大约阅读时间需要 20 分钟。

D. Dynamic Problem Scoring
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Input

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 ai, 1, ai, 2..., ai, 5 ( - 1 ≤ ai, 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

Output a single integer — the number of new accounts Vasya needs to beat Petya, or -1 if Vasya can't achieve his goal.

Examples
input
2 5 15 40 70 115 50 45 40 30 15
output
2
input
3 55 80 10 -1 -1 15 -1 79 60 -1 42 -1 13 -1 -1
output
3
input
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
output
27
input
4 -1 20 40 77 119 30 10 73 50 107 21 29 -1 64 98 117 65 -1 -1 -1
output
-1
Note

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.

心态炸了,这道题暴力可以过啊,忧伤。。。。也就是读懂提议基本就可以了,两个人比赛呢,用的是CF这种分数赛制林林总总的,英语太重要啦

#include
using namespace std;int a[150][150];int cnt[10];int n;int getsc(int id, bool f, int s) { if(a[f][id]==-1) return 0; int sum; if(a[0][id] == -1 || a[1][id] == -1 || a[0][id]
n+s) break; else sc += 500; } return sc*(250.0 - a[f][id])/250.0;}int main() { cin >> n; for(int i = 0; i < n; ++i) for(int j = 0; j < 5; ++j) { cin >> a[i][j]; if(a[i][j]!= -1) cnt[j]++; } for(int i = 0; i < 50000; ++i) { int a1=0, a2=0; for(int j = 0; j < 5; ++j) a1 += getsc(j, 0, i); for(int j = 0; j < 5; ++j) a2 += getsc(j, 1, i); if(a1 > a2) { cout << i << endl; return 0; } } cout << "-1" <
View Code

 

 

转载于:https://www.cnblogs.com/BobHuang/p/6843427.html

你可能感兴趣的文章
Google AI子公司采用区块链技术来跟踪英国的健康数据
查看>>
力成科技股东会决议通过紫光投资案
查看>>
推荐10款免费的在线UI测试工具
查看>>
《嵌入式系统数字视频处理权威指南》—— 导读
查看>>
侵犯公民个人信息: “两高”首次出台司法解释 打击大数据征信乱象
查看>>
《Photoshop修色圣典(第5版)》—第1章1.13节你将是裁判
查看>>
《大数据算法》一2.4 数组有序的判定算法
查看>>
我的友情链接
查看>>
Xcode 7 缺少 *.dylib库的解决方法
查看>>
【MyBatis】缓存配置
查看>>
搭建nonde项目结构
查看>>
URL Management(网址管理)
查看>>
新手站长们看过来:白话ID
查看>>
Linux基础命令试题——第二周
查看>>
HighChart教程:如何使用Highcharts Cloud API(二)
查看>>
一句话,讲清楚java泛型的本质(非类型擦除)
查看>>
百度联合清华发布国内首个基于AI实践的产业智能化白皮书
查看>>
我的友情链接
查看>>
博文第一篇《明志》
查看>>
java Stack类 Vector类
查看>>