• Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) A B C D 水 模拟 二分 贪心


    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 改变则必然记分了 若比赛前后分数均相等 则判断初始分是否降序 若不满足降序则一定未记分。

     1 #include<iostream>
     2 #include<cstdio>
     3 #include<cstring>
     4 #include<map>
     5 #define ll __int64
     6 #define mod 1000000007
     7 #define N 100005
     8 using namespace std;
     9 int n;
    10 int a[N];
    11 int b[N];
    12 int main()
    13 {
    14     scanf("%d",&n);
    15     for(int i=1;i<=n;i++)
    16     {
    17         scanf("%d %d",&a[i],&b[i]);
    18     }
    19     for(int i=1;i<=n;i++)
    20     {
    21         if(a[i]!=b[i])
    22         {
    23             printf("rated
    ");
    24             return 0;
    25         }
    26     }
    27     for(int i=1;i<n;i++)
    28     {
    29         if(a[i+1]>a[i])
    30         {
    31             printf("unrated");
    32             return 0;
    33         }
    34     }
    35     printf("maybe");
    36     return 0;
    37 }
    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;

     1 #include<iostream>
     2 #include<cstdio>
     3 #include<cstring>
     4 #include<map>
     5 #define ll __int64
     6 #define mod 1000000007
     7 #define N 100005
     8 using namespace std;
     9 int p,x,y;
    10 int main()
    11 {
    12     scanf("%d %d %d",&p,&x,&y);
    13     int ans=0;
    14     int flag=0;
    15     int xx=x;
    16     int yy=y;
    17     while(xx>=yy)
    18     {
    19          int s=(xx/50)%475;
    20           for(int i=1;i<=25;i++)
    21           {
    22               s=(s*96+42)%475;
    23               if((s+26)==p)
    24               {
    25                   flag=1;
    26               }
    27               if(flag==1)
    28               break;
    29           }
    30           xx-=50;
    31           if(flag==1)
    32               break;
    33     }
    34     if(flag==1)
    35     {
    36      printf("0
    ");
    37      return 0;
    38     }
    39     flag=0;
    40     while(1)
    41     {
    42         if(x<y)
    43         {
    44             x+=50;
    45             ans++;
    46         }
    47         else
    48         {
    49           int s=(x/50)%475;
    50           for(int i=1;i<=25;i++)
    51           {
    52               s=(s*96+42)%475;
    53               if((s+26)==p)
    54               {
    55                   flag=1;
    56               }
    57               if(flag==1)
    58               break;
    59           }
    60           if(flag==0){
    61             ans++;
    62             x+=50;
    63             }
    64         }
    65         if(flag==1)
    66             break;
    67     }
    68     if(ans%2==0)
    69     printf("%d
    ",ans/2);
    70     else
    71     printf("%d
    ",ans/2+1);
    72     return 0;
    73 }
    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率。

     1 #include<iostream>
     2 #include<cstdio>
     3 #include<cstring>
     4 #include<map>
     5 #define ll __int64
     6 #define mod 1000000007
     7 #define N 100005
     8 using namespace std;
     9 ll x,y,p,q;
    10 bool check(ll s)
    11 {
    12     ll pp,qq;
    13     pp=p*s;
    14     qq=q*s;
    15     if(y>qq)
    16         return false;
    17     else
    18     {
    19         ll exm=qq-y;
    20 
    21         if(pp>=x&&pp<=(x+exm))
    22             return true;
    23         else
    24             return false;
    25     }
    26 }
    27 int main()
    28 {
    29     int t;
    30     scanf("%d",&t);
    31     for(int i=1;i<=t;i++)
    32     {
    33         scanf("%I64d %I64d %I64d %I64d",&x,&y,&p,&q);
    34         ll l=1,r=1e9,mid;
    35         while(l<r)
    36         {
    37             mid=(l+r)/2;
    38             if(check(mid))
    39                 r=mid;
    40             else
    41                 l=mid+1;
    42         }
    43         if(check(r))
    44             printf("%I64d
    ",q*r-y);
    45         else
    46             printf("-1
    ");
    47     }
    48     return 0;
    49 }
    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率便不再改变。

      1 #include<iostream>
      2 #include<cstdio>
      3 #include<cstring>
      4 #include<map>
      5 #define ll __int64
      6 #define mod 1000000007
      7 #define N 100005
      8 using namespace std;
      9 int n;
     10 int a[10];
     11 int s1[10],s2[10],s3[10];
     12 int check(double x)
     13 {
     14     if(x>(1/2.0))
     15         return 500;
     16     else if(x>(1/4.0))
     17         return 1000;
     18     else if(x>(1/8.0))
     19         return 1500;
     20     else if(x>(1/16.0))
     21         return 2000;
     22     else if(x>(1/32.0))
     23         return 2500;
     24     else return 3000;
     25 }
     26 int main()
     27 {
     28     int n;
     29     memset(a,0,sizeof(a));
     30     scanf("%d",&n);
     31     scanf("%d %d %d %d %d",&s1[1],&s1[2],&s1[3],&s1[4],&s1[5]);
     32     if(s1[1]!=-1) a[1]++;
     33     if(s1[2]!=-1) a[2]++;
     34     if(s1[3]!=-1) a[3]++;
     35     if(s1[4]!=-1) a[4]++;
     36     if(s1[5]!=-1) a[5]++;
     37     scanf("%d %d %d %d %d",&s2[1],&s2[2],&s2[3],&s2[4],&s2[5]);
     38     if(s2[1]!=-1) a[1]++;
     39     if(s2[2]!=-1) a[2]++;
     40     if(s2[3]!=-1) a[3]++;
     41     if(s2[4]!=-1) a[4]++;
     42     if(s2[5]!=-1) a[5]++;
     43     for(int i=3; i<=n; i++){
     44         scanf("%d %d %d %d %d",&s3[1],&s3[2],&s3[3],&s3[4],&s3[5]);
     45         if(s3[1]!=-1) a[1]++;
     46         if(s3[2]!=-1) a[2]++;
     47         if(s3[3]!=-1) a[3]++;
     48         if(s3[4]!=-1) a[4]++;
     49         if(s3[5]!=-1) a[5]++;
     50     }
     51     int flag[10];
     52     if(s1[1]==-1)
     53         flag[1]=0;
     54     else{
     55         if(s2[1]==-1)
     56             flag[1]=0;
     57         else if(s1[1]<s2[1])
     58             flag[1]=0;
     59         else  flag[1]=1;
     60     }
     61     if(s1[2]==-1)
     62         flag[2]=0;
     63     else{
     64         if(s2[2]==-1)
     65             flag[2]=0;
     66         else if(s1[2]<s2[2])
     67             flag[2]=0;
     68         else  flag[2]=1;
     69     }
     70 
     71      if(s1[3]==-1)
     72         flag[3]=0;
     73     else{
     74         if(s2[3]==-1)
     75             flag[3]=0;
     76         else if(s1[3]<s2[3])
     77             flag[3]=0;
     78         else  flag[3]=1;
     79     }
     80 
     81      if(s1[4]==-1)
     82         flag[4]=0;
     83     else{
     84         if(s2[4]==-1)
     85             flag[4]=0;
     86         else if(s1[4]<s2[4])
     87             flag[4]=0;
     88         else  flag[4]=1;
     89     }
     90 
     91       if(s1[5]==-1)
     92         flag[5]=0;
     93      else{
     94         if(s2[5]==-1)
     95             flag[5]=0;
     96         else if(s1[5]<s2[5])
     97             flag[5]=0;
     98         else  flag[5]=1;
     99      }
    100        int  exm1=0,exm2=0;
    101        if(s1[1]!=-1) exm1+=check((((double)(a[1]))/n))*(1-s1[1]/250.0);
    102        if(s1[2]!=-1) exm1+=check((((double)(a[2]))/n))*(1-s1[2]/250.0);
    103        if(s1[3]!=-1) exm1+=check((((double)(a[3]))/n))*(1-s1[3]/250.0);
    104        if(s1[4]!=-1) exm1+=check((((double)(a[4]))/n))*(1-s1[4]/250.0);
    105        if(s1[5]!=-1) exm1+=check((((double)(a[5]))/n))*(1-s1[5]/250.0);
    106 
    107        if(s2[1]!=-1) exm2+=check((((double)(a[1]))/n))*(1-s2[1]/250.0);
    108        if(s2[2]!=-1) exm2+=check((((double)(a[2]))/n))*(1-s2[2]/250.0);
    109        if(s2[3]!=-1) exm2+=check((((double)(a[3]))/n))*(1-s2[3]/250.0);
    110        if(s2[4]!=-1) exm2+=check((((double)(a[4]))/n))*(1-s2[4]/250.0);
    111        if(s2[5]!=-1) exm2+=check((((double)(a[5]))/n))*(1-s2[5]/250.0);
    112        if(exm1>exm2){
    113         printf("0
    ");
    114         return 0;
    115      }
    116        int re=n;
    117        for(int i=1;i<=50000;i++){
    118         exm1=0;
    119         exm2=0;
    120         n++;
    121         a[1]+=flag[1];
    122         a[2]+=flag[2];
    123         a[3]+=flag[3];
    124         a[4]+=flag[4];
    125         a[5]+=flag[5];
    126        if(s1[1]!=-1) exm1+=check((((double)(a[1]))/n))*(1-s1[1]/250.0);
    127        if(s1[2]!=-1) exm1+=check((((double)(a[2]))/n))*(1-s1[2]/250.0);
    128        if(s1[3]!=-1) exm1+=check((((double)(a[3]))/n))*(1-s1[3]/250.0);
    129        if(s1[4]!=-1) exm1+=check((((double)(a[4]))/n))*(1-s1[4]/250.0);
    130        if(s1[5]!=-1) exm1+=check((((double)(a[5]))/n))*(1-s1[5]/250.0);
    131 
    132        if(s2[1]!=-1) exm2+=check((((double)(a[1]))/n))*(1-s2[1]/250.0);
    133        if(s2[2]!=-1) exm2+=check((((double)(a[2]))/n))*(1-s2[2]/250.0);
    134        if(s2[3]!=-1) exm2+=check((((double)(a[3]))/n))*(1-s2[3]/250.0);
    135        if(s2[4]!=-1) exm2+=check((((double)(a[4]))/n))*(1-s2[4]/250.0);
    136        if(s2[5]!=-1) exm2+=check((((double)(a[5]))/n))*(1-s2[5]/250.0);
    137 
    138        if(exm1>exm2){
    139                 printf("%d
    ",n-re);
    140                 return 0;
    141             }
    142     }
    143     printf("-1
    ");
    144     return 0;
    145 }
  • 相关阅读:
    2017"百度之星"程序设计大赛
    2018省赛赛第一次训练题解和ac代码
    2018天梯赛第一次训练题解和ac代码
    rsa Round #71 (Div. 2 only)
    AtCoder Grand Contest 021
    Hello 2018
    Educational Codeforces Round 36 (Rated for Div. 2)
    Codeforces Round #462 (Div. 2)
    Codeforces Round #467 (Div. 2)
    [Offer收割]编程练习赛48
  • 原文地址:https://www.cnblogs.com/hsd-/p/6826918.html
Copyright © 2020-2023  润新知