Problem Description
Considering the overall difficulty of other problems, we invite Quailty to propose an easy problem for this contest.
Quailty accidentally won both gold medal and silver medal in 2017 CCPC final. The reason is explained as follows. According to the official rule, the number of gold medals was 10\% of the number of participating teams, rounded to the nearest integer. This is ambiguous when the fractional part of the result is exactly 0.5. There were 115 participating teams, and the rank of Quailty‘s team was 12. The organizer originally decided to round down the number, so there were only 11 gold medals, and Quailty‘s team could only win the silver medal. Many people defended him against the organizer, saying that his team deserved a gold medal. Later, the organizer changed to round up the number, and Quailty‘s team finally won a gold medal.
Now, give you the scoreboard of a contest and the proportion of gold medal teams, could you determine whether there exists a team, such that they would win a gold medal were the number of gold medals rounded up when the fractional part is exactly 0.5, and silver medal if rounded down?
A team ranks before another if they solved more problems or both teams solved an equal number of problems but they had less penalty time.
(Disclaimer: the background is fictitious and the problem is prepared by Nanjing University ICPC Training Team, not Quailty.)
Input
The first line of input consists of a single integer T (1≤T≤120), denoting the number of test cases.
Each test case starts with a line of two integers n (1≤n≤105), denoting the number of participating teams, and d (0≤d≤9), denoting that the proportion of gold medal teams is 10d%. For the next n lines, each containing a string s and two integers p,t (0≤p,t≤109), denoting the name of the team, the number of problems solved and the penalty time of the team, respectively. The name of the each team contains at least 1 and at most 10 latin letters. The names are case sensitive. No two teams have the same name. No two teams have the same penalty time. The sum of n over all test cases does not exceed 106.
Output
For each test case, print the team name if there exists such team, or print Quailty is very great otherwise. It can be proved that there is at most one such team.
Sample Input
2
5 1
Ace 1000 0
Luffy 999 1
Sabo 998 2
Roronoa 997 3
Sanji 996 4
2 3
You 0 0
I 10 1
Sample Output
Ace
Quailty is very great
解题报告:一开始这个题目就像刹不住车一样,大家哗哗的出这道题目,我和队友看了好久才明白这个题目的意义,就是一道精度水题,需要看看金牌的比例最后是不是X.5 ,如果是的话,请输出这个恰好卡在这个位置的人的姓名,不是直接输出那句话, 但是在处理精度上wa了两次,没有处理好。
ac代码:
1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<algorithm> 5 #include<queue> 6 #include<stack> 7 #include<set> 8 #include<map> 9 #include<vector> 10 #include<cmath> 11 #define eps 1e-6 12 13 14 const int maxn=1e5+5; 15 typedef long long ll; 16 using namespace std; 17 struct node 18 { 19 char name[15]; 20 int num,tt; 21 }p[maxn]; 22 23 bool cmp(node x,node y) 24 { 25 if(x.num!=y.num) 26 { 27 return x.num>y.num; 28 } 29 else 30 { 31 return x.tt<y.tt; 32 } 33 } 34 35 int main() 36 { 37 int T; 38 cin>>T; 39 int n,d; 40 while(T--) 41 { 42 scanf("%d%d",&n,&d); 43 for(int t=0;t<n;t++) 44 { 45 scanf("%s%d%d",p[t].name,&p[t].num,&p[t].tt); 46 } 47 sort(p,p+n,cmp); 48 double s=n*(0.1)*d; 49 if((s-floor(s))>=0.5-eps&&s-floor(s)<=0.5+eps) 50 { 51 int tmp=ceil(s); 52 printf("%s\n",p[tmp-1]); 53 } 54 else 55 { 56 puts("Quailty is very great"); 57 } 58 } 59 system("pause"); 60 return 0; 61 }
原文地址:https://www.cnblogs.com/Spring-Onion/p/11354746.html