codeforces807div2 D.Dynamic Problem Scoring[暴力][贪心]

CSV文件输入到simulink中 将示波器波形和数据CSV文件保存下来进行数据分析。将波形绘制到simulink中 阅读详情

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) = 1680points 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.



题意:两个好朋友参加一场动态计分的比赛,根据比赛要求,每个题的分数与题的正确比率有关,每个人的每个题得分与作出题的时间和题目分数有关。为了让A战胜B,A开了很多小号来提交正确或错误,问最少的提交次数能战胜B。

思路:

一共初始状态最多120人参赛,所以为了让一个题的分数限定在500分或者3000分, 只需要大约3000个小号,所以五个题最多需要上万个小号吧,再多了也没有什么作用,所以对使用小号的个数进行暴力即可,针对每个小号如何提交才能达到最优状态,采用贪心的方式:

如果A没有做出来这题,所有小号一定无法正确提交。

如果A做出来了这题,但是B没有做出来,为了使此题分数最大,A的小号都提交错误答案。

如果A做出来了这题,B也做出来了,但是A比B做的快,次情况同上。

如果A做出来了,但B做的比A快,为了使此题分数最小,A的小号都正确提交。

按照以上贪心方式提交,即可判断当前小号个数下五个题的分数谁高,是否满足条件。

(比较坑的一点代码中计算 *(1-x/250)这里精度出错了)

#include<bits/stdc++.h>
using namespace std;
int a[150][150];
int cnt[10];
int n;
int getscore(int id, bool flag, int s)
{
    if(a[flag][id]==-1) return 0;
    int sum;
    if(a[0][id] == -1 || a[1][id] == -1 || a[0][id]<a[1][id]) sum = cnt[id];
    else sum = cnt[id]+s;

    int score = 500;
    for(int i = 2; i <= 32; i*=2)
    {
        if(sum*i > n+s)
            break;
        else score += 500;
    }

    return score*(250.0 - a[flag][id])/250.0;
}


int main()
{
    ios::sync_with_stdio(false);
    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]++;
    }
    //cout << getscore(4, 0, 2);
    for(int i = 0; i < 50000; ++i)
    {
        int a1=0, a2=0;
        for(int j = 0; j < 5; ++j)
            a1 += getscore(j, 0, i);
        for(int j = 0; j < 5; ++j)
            a2 += getscore(j, 1, i);
        //cout << a1 <<" " <<  a2 << endl;
        if(a1 > a2)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1" <<endl;
    return 0;
}



从零搭建AGV避障系统:我用激光雷达+树莓派视觉模块踩过的那些坑 本文分享了基于树莓派与国产激光雷达从零搭建低成本AGV避障系统的实战经验。针对复杂仓库环境,详细剖析了激光雷达数据噪声、视觉模块算力瓶颈、IMU漂移等核心挑战,并提供了多传感器融合、软件架构设计与避障决策的具体解决方案,为中小型自动化改造项目提供了宝贵参考。 阅读详情

相关推荐

ComfyUI 的 LoRA 训练:秋叶 LoRA-scripts 参数设置与测试方法详解

秋叶 LoRA-scripts 的参数设置需结合理论(如模型原理、优化器机制)和硬件条件(显存、算力),新手可先按推荐值起步,再逐步调整。测试时,loss 值帮你判断训练是否正常,XYZ 图表法帮你找到最佳使用参数。掌握这些知识,你就能避开 LoRA 训练的常见坑,从 “盲目调参” 变为 “精准训练”。

2301_78150483的博客 2398

AC日记——Dynamic Problem Scoring codeforces 807d

Dynamic Problem Scoring 思路:   水题; 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 130 ...

weixin_34220834的博客 133

Moltemplate建模----水盒子data文件

1功能介绍 Moltemplate是LAMMPS官方支持的建模工具之一,适用于LAMMPS建模。该程序创建了一种简单的文件格式来存储分子定义和力场,即模板LT。LT文件包含与特定分子有关的所有文本(包括坐标,键拓扑,角度,力场参数,约束,组和修复)。 Moltemplate可以复制分子,对其进行自定义,然后用它作为构建更大、更复杂分子的基础。构建后,可以自定义...

元素魔方科研服务 2593

codeforces 412 D Dynamic Problem Scoring

题意:两个人比赛,得分规则如下:           每个题目的分值如下,                      其中的分数代表,解决这道题目的人数占总比赛人数的比例;           每个人可以得的分数如下: 题目分值*(1-此人解决这道题目所用时间/250); 在比赛的所有的人当中有两个人,其中一个人的编号为0,名字为Vasya,另一个编号为1 ,名字为Petya,现在

Ma_tx 339

手把手教你用RTD2775QT/RTD2795QT打造4K便携屏:从芯片选型到Type-C一线通实战

本文详细介绍了如何利用RTD2775QT和RTD2795QT显示驱动芯片打造4K便携屏的全过程,包括芯片选型、硬件设计、固件烧录及Type-C一线通实战方案。特别针对新手常见问题提供了解决方案,帮助读者高效完成DIY项目,提升移动办公体验。

weixin_42520025的博客 711

DDR Study - LPDDR5 Power-Up and Initialization Sequence

本文深入解析LPDDR5内存的上电初始化流程,涵盖电源斜坡、复位信号释放和初始化训练等关键阶段。通过实际案例分享,详细探讨了电源轨时序、RESET信号处理、ZQ校准和CA总线训练等核心技术要点,帮助硬件工程师规避常见设计陷阱,确保DDR内存稳定运行。

weixin_42523792的博客 299

codeforces807div2 C.Success Rate[二分][数学]

C. Success Rate time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are an experienced Codeforces user. Tod

Qer的博客 590

光猫改桥接后,一根网线搞定IPTV和上网的保姆级教程(附VLAN配置避坑点)

本文详细介绍了光猫改桥接后如何通过单线复用技术实现IPTV和上网功能共存。从VLAN配置原理到具体操作步骤,包括光猫超级管理员权限获取、VLAN绑定设置及路由器IPTV功能配置,提供了全面的保姆级教程。特别针对常见问题如IPTV信号丢失、网速下降等给出了实用解决方案,帮助用户轻松避坑。

weixin_29927965的博客 1734

codeforces D. Dynamic Problem Scoring

题意: 给出n个人5道题的codeforces提交时间,现在第一个人想要自己的成绩总和大于第二 个人,怎么强行提高自己成绩呢?他会开小号去提交某一些题目,而一道题的 Accepted之后的成绩是根据比例计算的,Accepted / 总提交。比例越小成绩越高 如题中的表。他可以在自己能力范围内控制题目的比例。求出,他需要多少个小号 去达到目的。 思路: 对于第一个人,如

Since_natural_ran 471

微信小程序 - 解决请求报错 request:fail errcode:-201 cronet_error_code:-201 error_msg:net::ERR_CERT_DATE_INVALID

微信小程序报错“request:fail errcode:-201 cronet_error_code:-201 error_msg:net::ERR_CERT_DATE_INVALID“,微信小程序请求报错,微信小程序errcode:-201,服务器报错,无法调用接口,微信小程序真机https请求失败,微信小程序wx.request接口报错,小程序真机调试运行接口都报错了,真机测试下网络请求都不行了且报错,证书没问题依旧报错,检查HTTPS证书,ssl证书,使用浏览器测试访问证书是正常的,不是证书问题,请

🏆 前端领域优质创作者 1万+

【数据集总结】不透水面积ISA:GAIA、CLUD-Urban、GISA

【数据集总结】不透水面积ISA:GAIA、CLUD-Urban、GISA

WW、forever的博客 2153

codeforces 807 D. Dynamic Problem Scoring(贪心+思维)

题目链接:http://codeforces.com/contest/807/problem/D 题意:对于动态计分的 Codeforces Round ,已知每题的 score 是根据 Round 参加人数和该题过题人数计算,两者之比结合上图得出该题的分数。某人在该题的得分为score*(1−t/250)其中 t 表示通过该题的时间。 已知参加该场比赛的所有参加者的过题情况(包...

awow80285的博客 192

10、现代统计方法:趋势面分析、薄板样条与广义线性模型

本文系统介绍了空间预测建模中的三种现代统计方法:趋势面分析(TSA)、薄板样条(TPS)和广义线性模型(GLM)。详细阐述了每种方法的原理、实现步骤、参数优化与预测评估,并结合R语言代码示例展示了在实际数据中的应用。文章还提供了方法对比流程图与土壤湿度预测案例,帮助读者根据数据特征选择合适模型,提升空间预测的准确性与可靠性。

play7的博客 156

Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) D. Dynamic Problem Scoring 贪心

&#13; 链接:&#13; http://codeforces.com/contest/807/problem/D&#13; 题意:&#13; 一场比赛一共5道题,有n个参赛者,现在只关心前两个,要使第一个人最后得分比第二个人高&#13; 每道题的总分数和通过这道题的人数与总人数的比值有关,如下表&#13; &#13; 现在给出每个人的每道题的通过时间,如果没有通过,时间为...

花海 126

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

Codeforces Round #412 (Div. 2)(Codeforces 807 ABCDE)

Codeforces Round #412 (Div. 2, base on VK Cup 2017 Round 3)比赛时过了3题,rating暴涨90+。。一定是上次只做出一题拉低了rating。。这场感觉AB都是题面杀。。然后比赛时看了DE感觉都可做,赛后补了一下。 官方题解依旧是高质量,耐心读,即使是会的题,也绝对收获不少。样例代码也很棒。 官方题解传送门:%touristCodefor

P.H.S 757

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

Codeforces Round #807 (Div. 2) A-C题解

CF Round 807 Div2 题解 Codeforces Round #807 Div 2. Editorial

GoWilli的优快云 469

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

Codeforces_807

A. 严格按照题目给的两个条件来。 #include<bits/stdc++.h> using namespace std; int n,a[1005],b[1005]; int main() { ios::sync_with_stdio(false); cin >> n; for(int i = 1;i &...

diaotan0836的博客 151

Codeforces Round #412 D. Dynamic Problem Scoring (枚举 + 贪心)

参考http://blog.csdn.net/dormousenone/article/details/71422868题意对于动态计分的 Codeforces Round ,已知每题的 score 是根据 Round 参加人数和该题过题人数计算,两者之比结合上图得出该题的分数。某人在该题的得分为 score×(1−t/250) 其中 t 表示通过该题的时间。已知参加该场比赛的所有参加者的过题情况(

now_ing的博客 338

# CF #807 Div.2(A - D)

​给定2n个数和k,请问是否存在n对(i,j)abs(ai-aj)>=k​先排序然后对1和n+1,2和n+2连续比对。​赛时拖了节奏因为看成了==k下次注意读题。

DM010maker的博客 395

codeforces807div2 E.Prairie Partition[二分]

E. Prairie Partition time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output It can be shown that any positive inte

Qer的博客 794

764E Timofey and remoduling[数学]

E. Timofey and remoduling time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little Timofey likes integers a l

Qer的博客 715

B. The Queue codeforces398div2

B. The Queue time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Finally! Vasya have come of age and that means

Qer的博客 660

761D Dasha and Very Difficult Problem[数学][思维]

D. Dasha and Very Difficult Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Dasha logged into the s

Qer的博客 563

764D Timofey and rectangles[思维][染色]

D. Timofey and rectangles time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One of Timofey's birthday present

Qer的博客 534

HDU5972Regular Number [shiftand][字符串]

题意:给定n个集合,每个集合中有一些数字,问给出的一个长数字串中的所有匹配。 匹配:如果连续n个数字分别出现在1~n这些集合中,则是一个成功的匹配。 考虑每个数字出现的集合,用十个01二进制表示0~9这十个数字出现在那些集合中(预处理占位),然后通过左移操作和与运算验证是否匹配到n位。 使用bitset更方便操作。#include<bits/stdc++.h> using namespace s

Qer的博客 418
上一篇: codeforces807div2 C.Success Rate[二分][数学]
下一篇: codeforces807div2 E.Prairie Partition[二分]
Qer_
博客等级 码龄11年 34粉丝 69原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值