Quailty and CCPC

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

时间: 2024-10-20 23:13:25

Quailty and CCPC的相关文章

HDOJ-6666(简单题+模拟题)

quailty and ccpc hdoj-6666 题目很简单,按照题目的意思模拟就行了,排序. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<string> using namespace std; struct node{ string name; int num; int time; node(){} node(stri

2019 杭电多校 第八场

2019 Multi-University Training Contest 8 补题链接:2019 Multi-University Training Contest 8 1003 Acesrc and Good Numbers HDU 6659 题意 定义 \(f(d, n)\) 为十进制下 \(1\) 到 \(n\) 所有数的数位中数字 \(d\) 出现的次数.给定 \(x\),找出最大的 \(n(n \le x)\) 满足 \(f(d, n) = n\). 题解 看到了一个神仙做法. 显

2015南阳CCPC L - Huatuo&#39;s Medicine 水题

L - Huatuo's Medicine Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description Huatuo was a famous doctor. He use identical bottles to carry the medicine. There are different types of medicine. Huatuo put medicines into the bottles and chain these b

hdu6153 A Secret CCPC网络赛 51nod 1277 KMP

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=6153 题意: 给出两个字符串S1,S2,求S2的所有后缀在S1中出现的次数与其长度的乘积之和. 思路: CCPC网络赛题解: https://post.icpc-camp.org/d/714-ccpc-2017 http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1277   是一样的 将s1,s2翻转,转化为求前缀在s1中出

CCPC杭州赛总结

相比于之前的比赛,这次比赛我没有任何包袱,轻装上阵,热身赛前两天晚上八点坐公交车去火车站,路上堵车,差点错过火车,还好一切顺利到了杭州预定的宾馆,这已经是热身赛前一天的下午四点钟了,相当于20个小时的车程,晚上和河南学校的一群大佬在一起聊天(虽然我并没有说很多话).    睡一觉醒来已经是热身赛那天的上午,和队友zjd&&zgp还有在杭州工作的学姐wh一起去杭电报道领取参赛服以及参赛手册等物品,接着就在杭电吃了午饭,又在杭电转了一圈,闲暇之余看到了狗狗和鸭子在湖中长达十分钟之久的追逐大战,

树形DP CCPC网络赛 HDU5834 Magic boy Bi Luo with his excited tree

1 // 树形DP CCPC网络赛 HDU5834 Magic boy Bi Luo with his excited tree 2 // 题意:n个点的树,每个节点有权值为正,只能用一次,每条边有负权,可以走多次,问从每个点出发的最大获益 3 // 思路: 4 // dp[i]: 从i点出发回到i点的最大值 5 // d[i][0] 从i点出发不回来的最大值 6 // d[i][1] 从i点出发取最大值的下一个点 7 // d[i][2] 从i点出发取次大值 8 // dfs1处理出这四个 9

CCPC 2017 网络赛

1001.我们的想法是,先构造n个要删掉的点,然后不断给图加边,使得每条边的其中一个点在n个点之中. 我们要使n个点之外的点尽量多,并且每次删掉的点在n个点之外. 贪心的决策是,每次操作,前n个点的度和令外的最大度的点度数相同. 然后删掉这个点之后,之后的操作,剩余的点也满足这个要求.所以度数最大的点必定与n个点有边. 于是可以这样构造,增加n批点(i = 1~n),每次增加n/i个点的,每个增加的点连出i条边到n个点. 这样,n个点每次增加的最大度数不超过1.但每次删点的时候(按n~1批的顺序

2016 CCPC 东北地区重现赛

1. 2016 CCPC 东北地区重现赛 2.总结:弱渣,只做出01.03.05水题 08   HDU5929 Basic Data Structure    模拟,双端队列 1.题意:模拟一个栈的操作,并在每次询问时,计算栈项到栈底元素nand位运算的值. 2.总结:思路就是看距离栈底最近的0的后面1的个数的奇偶.试了好多种办法,最后还是双端队列简便.总之,贼恶心的题.. #include<iostream> #include<cstring> #include<cmath

2016 CCPC 网络赛 B 高斯消元 C 树形dp(待补) G 状压dp+容斥(待补) H 计算几何

2016 CCPC 网络赛 A - A water problem 水题,但读题有个坑,输入数字长度很大.. B - Zhu and 772002 题意:给出n个数(给出的每个数的质因子最大不超过2000),选出多个数相乘得b.问有多少种选法让b 为完全平方数. tags:高斯消元,求异或方程组解的个数.   好题 每个数先素数分解开.  对于2000以内的每个素数p[i],这n个数有奇数个p[i]则系数为1,偶数个则系数为0,最后n个数的p[i]系数异或和都要为0才会使得最后的积为完全平方数.