A. Is it rated?
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

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.

Input

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.

Output

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".

Examples
Input
6
3060 3060
2194 2194
2876 2903
2624 2624
3007 2991
2884 2884
Output
rated
Input
4
1500 1500
1300 1300
1200 1200
1400 1400
Output
unrated
Input
5
3123 3123
2777 2777
2246 2246
2246 2246
1699 1699
Output
maybe
Note

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 ;
}
B. T-Shirt Hunt
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

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?

Input

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

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.

Examples
Input
239 10880 9889
Output
0
Input
26 7258 6123
Output
2
Input
493 8000 8000
Output
24
Input
101 6800 6500
Output
0
Input
329 19913 19900
Output
8
Note

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 ;
}
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. 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?

Input

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.

Output

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.

Example
Input
4
3 10 1 2
7 14 3 8
20 70 2 7
5 6 1 1
Output
4
10
0
-1
Note

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 ;
}
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.

题意:给你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 水 模拟 二分 贪心的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. 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 =  ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. rz和sz上传下载文件

    安装软件包 yum install  lrzsz   上传文件,输入rz选择文件上传(可以按住shift键多选) # rz   sz 下载文件到本地,选择保存文件夹 # sz dd   xshell设 ...

  2. kubeadm构建k8s之Prometheus-operated监控(0.18.1)

    介绍: 大家好,k8s的搭建有许多方式,也有许多快速部署的,为了简化部署的复杂度,官方也提供了开源的kubeadm快速部署,最新1.10.x版本已经可以实现部署集群, 如果你对k8s的原理已经非常了解 ...

  3. 第四次ScrumMeeting博客

    第四次ScrumMeeting博客 本次会议于10月28日(六)22时整在3公寓725房间召开,持续15分钟. 与会人员:刘畅.辛德泰.窦鑫泽.张安澜.赵奕. 1. 每个人的工作(有Issue的内容和 ...

  4. nagios监控安装esxi的服务器(宿主机)

    首先,该博文大部分内容来自网络,少部分是自己监控过程中遇到的问题.如果有侵权,请联系告知!!! 现在互联网公司,有能力的都是自己研发监控系统,要么就是zabbix或者小米的监控,还都二次开发等等,可能 ...

  5. Spark SQL、DataFrame和Dataset——转载

    转载自:  Spark SQL.DataFrame和Datase

  6. gmssl

    一.安装 1.1 github地址 1.2 官网地址 由于我本地虚拟机跑的是centos,按照官网的安装步骤,没有安装成功.后来使用github上提供的安装步骤完美编译安装成功. 二.使用 由于gms ...

  7. DS06--图

    一.学习总结 1.图的思维导图 2.图学习体会 深度优先遍历与广度优先遍历 不同点:广度优先搜索,适用于所有情况下的搜索,但是深度优先搜索不一定能适用于所有情况下的搜索.因为由于一个有解的问题树可能含 ...

  8. 第5章 Linux 常用网络指令

    网络参数设定使用的指令 手动/自动设定与启动/关闭 IP 参数: ifconfig, ifup, ifdown ifconfig :查询.设定网络卡与 IP 网域等相关参数:ifup, ifdown: ...

  9. jsonFormater之应用

        html代码: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> ...

  10. 如何在Eclipse配置PyDev插件

    如何在Eclipse配置PyDev插件 | 浏览:1733 | 更新:2014-04-21 11:36 1 2 3 4 5 分步阅读 Eclipse配置PyDev插件 方法/步骤   从 Eclips ...