Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) A B C D 水 模拟 二分 贪心
2 seconds
256 megabytes
standard input
standard output
Is it rated?
Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.
Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.
It's known that if at least one participant's rating has changed, then the round was rated for sure.
It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.
In this problem, you should not make any other assumptions about the rating system.
Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not.
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants.
Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings.
If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe".
6
3060 3060
2194 2194
2876 2903
2624 2624
3007 2991
2884 2884
rated
4
1500 1500
1300 1300
1200 1200
1400 1400
unrated
5
3123 3123
2777 2777
2246 2246
2246 2246
1699 1699
maybe
In the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.
In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.
In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not.
题意:第一列为比赛前的rate 第二列为比赛后的rate 判断是否记分?或无法确定
题解:rate 改变则必然记分了 若比赛前后分数均相等 则判断初始分是否降序 若不满足降序则一定未记分。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#define ll __int64
#define mod 1000000007
#define N 100005
using namespace std;
int n;
int a[N];
int b[N];
int main()
{
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%d %d",&a[i],&b[i]);
}
for(int i=;i<=n;i++)
{
if(a[i]!=b[i])
{
printf("rated\n");
return ;
}
}
for(int i=;i<n;i++)
{
if(a[i+]>a[i])
{
printf("unrated");
return ;
}
}
printf("maybe");
return ;
}
2 seconds
256 megabytes
standard input
standard output
Not so long ago the Codecraft-17 contest was held on Codeforces. The top 25 participants, and additionally random 25 participants out of those who got into top 500, will receive a Codeforces T-shirt.
Unfortunately, you didn't manage to get into top 25, but you got into top 500, taking place p.
Now the elimination round of 8VC Venture Cup 2017 is being held. It has been announced that the Codecraft-17 T-shirt winners will be chosen as follows. Let s be the number of points of the winner of the elimination round of 8VC Venture Cup 2017. Then the following pseudocode will be executed:
i := (s div 50) mod 475
repeat 25 times:
i := (i * 96 + 42) mod 475
print (26 + i)
Here "div" is the integer division operator, "mod" is the modulo (the remainder of division) operator.
As the result of pseudocode execution, 25 integers between 26 and 500, inclusive, will be printed. These will be the numbers of places of the participants who get the Codecraft-17 T-shirts. It is guaranteed that the 25 printed integers will be pairwise distinct for any value of s.
You're in the lead of the elimination round of 8VC Venture Cup 2017, having x points. You believe that having at least y points in the current round will be enough for victory.
To change your final score, you can make any number of successful and unsuccessful hacks. A successful hack brings you 100 points, an unsuccessful one takes 50 points from you. It's difficult to do successful hacks, though.
You want to win the current round and, at the same time, ensure getting a Codecraft-17 T-shirt. What is the smallest number of successful hacks you have to do to achieve that?
The only line contains three integers p, x and y (26 ≤ p ≤ 500; 1 ≤ y ≤ x ≤ 20000) — your place in Codecraft-17, your current score in the elimination round of 8VC Venture Cup 2017, and the smallest number of points you consider sufficient for winning the current round.
Output a single integer — the smallest number of successful hacks you have to do in order to both win the elimination round of 8VC Venture Cup 2017 and ensure getting a Codecraft-17 T-shirt.
It's guaranteed that your goal is achievable for any valid input data.
239 10880 9889
0
26 7258 6123
2
493 8000 8000
24
101 6800 6500
0
329 19913 19900
8
In the first example, there is no need to do any hacks since 10880 points already bring the T-shirt to the 239-th place of Codecraft-17 (that is, you). In this case, according to the pseudocode, the T-shirts will be given to the participants at the following places:
475 422 84 411 453 210 157 294 146 188 420 367 29 356 398 155 102 239 91 133 365 312 449 301 343
In the second example, you have to do two successful and one unsuccessful hack to make your score equal to 7408.
In the third example, you need to do as many as 24 successful hacks to make your score equal to 10400.
In the fourth example, it's sufficient to do 6 unsuccessful hacks (and no successful ones) to make your score equal to 6500, which is just enough for winning the current round and also getting the T-shirt.
题意:排名p 当前分数x 终态最低分数y 现在通过hack来改变分数 hack成功+100失败-50 问最少的hack成功次数使得 p出现在 题目中给出的程序算出的25个数中 上面伪代码中s为当前分数 并且当前分数大于等于y
题解:从初始的分数开始判断。注意可能通过降低分数来达到目标并且ans=0;
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#define ll __int64
#define mod 1000000007
#define N 100005
using namespace std;
int p,x,y;
int main()
{
scanf("%d %d %d",&p,&x,&y);
int ans=;
int flag=;
int xx=x;
int yy=y;
while(xx>=yy)
{
int s=(xx/)%;
for(int i=;i<=;i++)
{
s=(s*+)%;
if((s+)==p)
{
flag=;
}
if(flag==)
break;
}
xx-=;
if(flag==)
break;
}
if(flag==)
{
printf("0\n");
return ;
}
flag=;
while()
{
if(x<y)
{
x+=;
ans++;
}
else
{
int s=(x/)%;
for(int i=;i<=;i++)
{
s=(s*+)%;
if((s+)==p)
{
flag=;
}
if(flag==)
break;
}
if(flag==){
ans++;
x+=;
}
}
if(flag==)
break;
}
if(ans%==)
printf("%d\n",ans/);
else
printf("%d\n",ans/+);
return ;
}
2 seconds
256 megabytes
standard input
standard output
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y.
Your favorite rational number in the [0;1] range is p / q. Now you wonder: what is the smallest number of submissions you have to make if you want your success rate to be p / q?
The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases.
Each of the next t lines contains four integers x, y, p and q (0 ≤ x ≤ y ≤ 109; 0 ≤ p ≤ q ≤ 109; y > 0; q > 0).
It is guaranteed that p / q is an irreducible fraction.
Hacks. For hacks, an additional constraint of t ≤ 5 must be met.
For each test case, output a single integer equal to the smallest number of submissions you have to make if you want your success rate to be equal to your favorite rational number, or -1 if this is impossible to achieve.
4
3 10 1 2
7 14 3 8
20 70 2 7
5 6 1 1
4
10
0
-1
In the first example, you have to make 4 successful submissions. Your success rate will be equal to 7 / 14, or 1 / 2.
In the second example, you have to make 2 successful and 8 unsuccessful submissions. Your success rate will be equal to 9 / 24, or 3 / 8.
In the third example, there is no need to make any new submissions. Your success rate is already equal to 20 / 70, or 2 / 7.
In the fourth example, the only unsuccessful submission breaks your hopes of having the success rate equal to 1
题意:x为ac数 y为提交数 现在求最少增加多少次提交(是否ac不确定) 使得 ac率为p/q
题解:二分倍数,check是否能够达到目标ac率。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#define ll __int64
#define mod 1000000007
#define N 100005
using namespace std;
ll x,y,p,q;
bool check(ll s)
{
ll pp,qq;
pp=p*s;
qq=q*s;
if(y>qq)
return false;
else
{
ll exm=qq-y; if(pp>=x&&pp<=(x+exm))
return true;
else
return false;
}
}
int main()
{
int t;
scanf("%d",&t);
for(int i=;i<=t;i++)
{
scanf("%I64d %I64d %I64d %I64d",&x,&y,&p,&q);
ll l=,r=1e9,mid;
while(l<r)
{
mid=(l+r)/;
if(check(mid))
r=mid;
else
l=mid+;
}
if(check(r))
printf("%I64d\n",q*r-y);
else
printf("-1\n");
}
return ;
}
2 seconds
256 megabytes
standard input
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.
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 a single integer — the number of new accounts Vasya needs to beat Petya, or -1 if Vasya can't achieve his goal.
2
5 15 40 70 115
50 45 40 30 15
2
3
55 80 10 -1 -1
15 -1 79 60 -1
42 -1 13 -1 -1
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
27
4
-1 20 40 77 119
30 10 73 50 107
21 29 -1 64 98
117 65 -1 -1 -1
-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.
题意:给你n个人5道题目的提交情况 -1为没有通过 其余的表示通过题目的时间 以便记录得分。 每一道题目的满分与ac率(ac人数/参与比赛的总人数)有关 具体参看题目中的表格 现在第一个人想通过创小号参与比赛(有提交代表参与,大号没有ac的题目小号不可能ac)的方式来改变某些题目的满分 从而在总分上超过第二个人 问最少要创建多少个小号 无法实现则输出-1
题解:具体的思想就是贪心 优势题目尽可能扩大优势 劣势题目尽可能减小劣势 。对每一个小号来说 5道题目的提交情况与ac情况都是相同的。所以枚举5000的小号的添加 判断即可。为什么次数有限呢?因为小号添加的多了之后 每道题的ac率便不再改变。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#define ll __int64
#define mod 1000000007
#define N 100005
using namespace std;
int n;
int a[];
int s1[],s2[],s3[];
int check(double x)
{
if(x>(/2.0))
return ;
else if(x>(/4.0))
return ;
else if(x>(/8.0))
return ;
else if(x>(/16.0))
return ;
else if(x>(/32.0))
return ;
else return ;
}
int main()
{
int n;
memset(a,,sizeof(a));
scanf("%d",&n);
scanf("%d %d %d %d %d",&s1[],&s1[],&s1[],&s1[],&s1[]);
if(s1[]!=-) a[]++;
if(s1[]!=-) a[]++;
if(s1[]!=-) a[]++;
if(s1[]!=-) a[]++;
if(s1[]!=-) a[]++;
scanf("%d %d %d %d %d",&s2[],&s2[],&s2[],&s2[],&s2[]);
if(s2[]!=-) a[]++;
if(s2[]!=-) a[]++;
if(s2[]!=-) a[]++;
if(s2[]!=-) a[]++;
if(s2[]!=-) a[]++;
for(int i=; i<=n; i++){
scanf("%d %d %d %d %d",&s3[],&s3[],&s3[],&s3[],&s3[]);
if(s3[]!=-) a[]++;
if(s3[]!=-) a[]++;
if(s3[]!=-) a[]++;
if(s3[]!=-) a[]++;
if(s3[]!=-) a[]++;
}
int flag[];
if(s1[]==-)
flag[]=;
else{
if(s2[]==-)
flag[]=;
else if(s1[]<s2[])
flag[]=;
else flag[]=;
}
if(s1[]==-)
flag[]=;
else{
if(s2[]==-)
flag[]=;
else if(s1[]<s2[])
flag[]=;
else flag[]=;
} if(s1[]==-)
flag[]=;
else{
if(s2[]==-)
flag[]=;
else if(s1[]<s2[])
flag[]=;
else flag[]=;
} if(s1[]==-)
flag[]=;
else{
if(s2[]==-)
flag[]=;
else if(s1[]<s2[])
flag[]=;
else flag[]=;
} if(s1[]==-)
flag[]=;
else{
if(s2[]==-)
flag[]=;
else if(s1[]<s2[])
flag[]=;
else flag[]=;
}
int exm1=,exm2=;
if(s1[]!=-) exm1+=check((((double)(a[]))/n))*(-s1[]/250.0);
if(s1[]!=-) exm1+=check((((double)(a[]))/n))*(-s1[]/250.0);
if(s1[]!=-) exm1+=check((((double)(a[]))/n))*(-s1[]/250.0);
if(s1[]!=-) exm1+=check((((double)(a[]))/n))*(-s1[]/250.0);
if(s1[]!=-) exm1+=check((((double)(a[]))/n))*(-s1[]/250.0); if(s2[]!=-) exm2+=check((((double)(a[]))/n))*(-s2[]/250.0);
if(s2[]!=-) exm2+=check((((double)(a[]))/n))*(-s2[]/250.0);
if(s2[]!=-) exm2+=check((((double)(a[]))/n))*(-s2[]/250.0);
if(s2[]!=-) exm2+=check((((double)(a[]))/n))*(-s2[]/250.0);
if(s2[]!=-) exm2+=check((((double)(a[]))/n))*(-s2[]/250.0);
if(exm1>exm2){
printf("0\n");
return ;
}
int re=n;
for(int i=;i<=;i++){
exm1=;
exm2=;
n++;
a[]+=flag[];
a[]+=flag[];
a[]+=flag[];
a[]+=flag[];
a[]+=flag[];
if(s1[]!=-) exm1+=check((((double)(a[]))/n))*(-s1[]/250.0);
if(s1[]!=-) exm1+=check((((double)(a[]))/n))*(-s1[]/250.0);
if(s1[]!=-) exm1+=check((((double)(a[]))/n))*(-s1[]/250.0);
if(s1[]!=-) exm1+=check((((double)(a[]))/n))*(-s1[]/250.0);
if(s1[]!=-) exm1+=check((((double)(a[]))/n))*(-s1[]/250.0); if(s2[]!=-) exm2+=check((((double)(a[]))/n))*(-s2[]/250.0);
if(s2[]!=-) exm2+=check((((double)(a[]))/n))*(-s2[]/250.0);
if(s2[]!=-) exm2+=check((((double)(a[]))/n))*(-s2[]/250.0);
if(s2[]!=-) exm2+=check((((double)(a[]))/n))*(-s2[]/250.0);
if(s2[]!=-) exm2+=check((((double)(a[]))/n))*(-s2[]/250.0); if(exm1>exm2){
printf("%d\n",n-re);
return ;
}
}
printf("-1\n");
return ;
}
Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) A B C D 水 模拟 二分 贪心的更多相关文章
- Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3)(A.B.C,3道暴力题,C可二分求解)
A. Is it rated? time limit per test:2 seconds memory limit per test:256 megabytes input:standard inp ...
- Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) D - Dynamic Problem Scoring
地址:http://codeforces.com/contest/807/problem/D 题目: D. Dynamic Problem Scoring time limit per test 2 ...
- Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) A Is it rated?
地址:http://codeforces.com/contest/807/problem/C 题目: C. Success Rate time limit per test 2 seconds mem ...
- Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) E. Prairie Partition 二分+贪心
E. Prairie Partition It can be shown that any positive integer x can be uniquely represented as x = ...
- Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) 菜鸡只会ABC!
Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) 全场题解 菜鸡只会A+B+C,呈上题解: A. Bear and ...
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2)(A.思维题,B.思维题)
A. Vicious Keyboard time limit per test:2 seconds memory limit per test:256 megabytes input:standard ...
- Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) C. Bear and Different Names 贪心
C. Bear and Different Names 题目连接: http://codeforces.com/contest/791/problem/C Description In the arm ...
- Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) B - Bear and Friendship Condition 水题
B. Bear and Friendship Condition 题目连接: http://codeforces.com/contest/791/problem/B Description Bear ...
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) D. Volatile Kite
地址:http://codeforces.com/contest/801/problem/D 题目: D. Volatile Kite time limit per test 2 seconds me ...
随机推荐
- PHP精确到毫秒秒杀倒计时实例
精确到毫秒秒杀倒计时PHP源码实例,前台js活动展示倒计时,后台计算倒计时时间.每0.1秒定时刷新活动倒计时时间. PHP: // 注意:php的时间是以秒算.js的时间以毫秒算 // 设置时区 da ...
- python项目通过配置文件方式配置日志-logging
背景:项目中引入日志是必须的,这里介绍通过配置文件config.ini的方式配置日志 1.新建config.ini 2.添加配置 [loggers]keys=root,ProxyIP [handler ...
- LeetCode 36. Valid Sudoku (C++)
题目: Determine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according t ...
- jquery新版本旧版本之间的坑
JQuery自1.6.1版本开始增加一些属性,使用时尽量使用这些新的属性,例如:selected.checked.在高版本中赋值时最好用prop,如果用attr就会出现赋值不成功的问题, 一般自定义属 ...
- Unicode 和 UTF-8 有何区别
作者:于洋链接:https://www.zhihu.com/question/23374078/answer/69732605来源:知乎著作权归作者所有,转载请联系作者获得授权. ========== ...
- Spring的事务到底该给Dao配置还是给Service配置
Spring的事务到底该给Dao配置还是给Service配置 Spring事务为业务逻辑进行事务管理,保证业务逻辑上数据的原子性. 事务得根据项目性质来细分:事务可以设置到三个层面(dao层.serv ...
- TCP系列42—拥塞控制—5、Linux中的慢启动和拥塞避免(二)
在本篇中我们继续上一篇文章wireshark的示例讲解,上一篇介绍了一个综合示例后,本篇介绍一些简单的示例,在读本篇前建议先把上一篇读完,为了节省篇幅,本篇只针对一些特殊的场景点报文进行讲解,不会像上 ...
- CentOS6.5 重启网络报错:Bringing up interface eth0: Error: Connection activation failed: Device not managed by NetworkManager or unavailable
CentOS6.5 重启网络报错: Bringing up interface eth0: Error: Connection activation failed: Device not manage ...
- i18n实现前端国际化(实例)
在今日的需求中需要利用 i18n 这个框架来实现前端的国家化操作,下图是实现效果: 点击选择框实现网页上语言的切换: 下面开始实现过程: 所需工具: - jquery-3.3.1.js 下载地址 ...
- 第130天:移动端-rem布局
一.关于布局方案 当拿到设计师给的UI设计图,前端的首要任务就是布局和样式,相信这对于大部分前端工程师来说已经不是什么难题了.移动端的布局相对PC较为简单,关键在于对不同设备的适配.之前介绍了一篇关于 ...