A. Elimination
time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output
The finalists of the "Russian Code Cup" competition in 2214 will be the participants who win in one of the elimination rounds.
The elimination rounds are divided into main and additional. Each of the main elimination rounds consists of c problems, the winners of the round are the first n people in the rating list. Each of the additional elimination rounds consists of d problems. The winner of the additional round is one person. Besides, k winners of the past finals are invited to the finals without elimination.
As a result of all elimination rounds at least n·m people should go to the finals. You need to organize elimination rounds in such a way, that at least n·m people go to the finals, and the total amount of used problems in all rounds is as small as possible.
The first line contains two integers c and d (1 ≤ c, d ≤ 100) — the number of problems in the main and additional rounds, correspondingly. The second line contains two integers n and m (1 ≤ n, m ≤ 100). Finally, the third line contains an integer k (1 ≤ k ≤ 100) — the number of the pre-chosen winners.
In the first line, print a single integer — the minimum number of problems the jury needs to prepare.
1 10
7 2
1
2
2 2
2 1
2
题意 :淘汰赛分为主赛和附加赛,主赛一轮有c道题,附加赛一轮有d道题,主赛每轮可以选拔出n个人,附加赛每次可以选出1个人,还有k个人不用参加淘汰赛,要求最后要选出m×n个人主办方需要准备的最少的题目是多少。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include <stdio.h> 2 #include <string.h> 3 #include <iostream> 4 5 using namespace std ; 6 7 int main() 8 { 9 int c,d ; 10 int n,m ; 11 int k ; 12 while(~scanf("%d %d",&c,&d)) 13 { 14 scanf("%d %d %d",&n,&m,&k) ; 15 if(n * m - k <= 0) 16 { 17 printf("0\n") ; 18 continue ; 19 } 20 int a = n*m-k ; 21 int ans = 0 ; 22 if(c < d*n) 23 { 24 int x = a / n ; 25 ans += x*c ; 26 int y = a % n ; 27 ans += min(c,d*y) ; 28 } 29 else 30 ans = a * d ; 31 printf("%d\n",ans) ; 32 } 33 return 0 ; 34 }
B. Crash
time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output
During the "Russian Code Cup" programming competition, the testing system stores all sent solutions for each participant. We know that many participants use random numbers in their programs and are often sent several solutions with the same source code to check.
Each participant is identified by some unique positive integer k, and each sent solution A is characterized by two numbers: x — the number of different solutions that are sent before the first solution identical to A, and k — the number of the participant, who is the author of the solution. Consequently, all identical solutions have the same x.
It is known that the data in the testing system are stored in the chronological order, that is, if the testing system has a solution with number x (x > 0) of the participant with number k, then the testing system has a solution with number x - 1 of the same participant stored somewhere before.
During the competition the checking system crashed, but then the data of the submissions of all participants have been restored. Now the jury wants to verify that the recovered data is in chronological order. Help the jury to do so.
The first line of the input contains an integer n (1 ≤ n ≤ 105) — the number of solutions. Each of the following n lines contains two integers separated by space x and k (0 ≤ x ≤ 105; 1 ≤ k ≤ 105) — the number of previous unique solutions and the identifier of the participant.
A single line of the output should contain «YES» if the data is in chronological order, and «NO» otherwise.
2
0 1
1 1
YES
4
0 1
1 2
1 1
0 2
NO
4
0 1
1 1
0 1
0 2
题意 :每一个上交的答案都有两个标志,x和k,代表k这个人交的第x个不一样的答案,然后给你n个x和k,问你是不是按照时间排得序,而这个按照时间排序的要求就是对于每一个大于0的x,都要求在前边出现过同一个人交过的x-1.否则输出NO
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include <stdio.h> 2 #include <string.h> 3 #include <iostream> 4 5 using namespace std ; 6 7 int a[100010] ; 8 int main() 9 { 10 int n,x,k ; 11 while(~scanf("%d",&n)) 12 { 13 bool flag = false ; 14 memset(a,-1,sizeof(a)) ; 15 for(int i = 1 ; i <= n ; i++) 16 { 17 scanf("%d %d",&x,&k) ; 18 if(a[k] == x-1) 19 a[k]++ ; 20 else if(a[k] < x-1) 21 flag = true ; 22 } 23 if(flag) printf("NO\n") ; 24 else printf("YES\n") ; 25 } 26 return 0 ; 27 }
C. Football
time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided inton teams and played several matches, two teams could not play against each other more than once.
The appointed Judge was the most experienced member — Pavel. But since he was the wisest of all, he soon got bored of the game and fell asleep. Waking up, he discovered that the tournament is over and the teams want to know the results of all the matches.
Pavel didn't want anyone to discover about him sleeping and not keeping an eye on the results, so he decided to recover the results of all games. To do this, he asked all the teams and learned that the real winner was friendship, that is, each team beat the other teams exactly k times. Help Pavel come up with chronology of the tournir that meets all the conditions, or otherwise report that there is no such table.
The first line contains two integers — n and k (1 ≤ n, k ≤ 1000).
In the first line print an integer m — number of the played games. The following m lines should contain the information about all the matches, one match per line. The i-th line should contain two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi). The numbers ai and bi mean, that in the i-th match the team with number ai won against the team with number bi. You can assume, that the teams are numbered from1 to n.
If a tournir that meets the conditions of the problem does not exist, then print -1.
3 1
1 2
2 3
3 1
题意 :就是n个队,每个队都刚好赢了其他队k次,当然,人两个队打比赛都不能超过两次。输出两个队的对号,前者赢了后者。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include <iostream> 2 #include <stdio.h> 3 #include <string.h> 4 5 using namespace std; 6 7 int main() 8 { 9 int n ,k; 10 while(scanf("%d %d",&n,&k) != EOF) 11 { 12 if(k*2 >= n) 13 { 14 printf("-1\n") ; 15 continue ; 16 } 17 printf("%d\n",n*k) ; 18 for(int i = 1 ; i <= n ; i++) 19 for(int j = i+1 ; j <= i+k ; j++) 20 printf("%d %d\n",i,(j-1) % n+1) ; 21 } 22 return 0; 23 }