ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Quailty and CCPC

2019-08-14 17:38:03  阅读:291  来源: 互联网

标签:gold number CCPC team teams medal Quailty


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

 

题解:用结构体存储队名,解题数,罚时,按要求排序并判断结果小数是不是0.5。

AC代码:

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;

struct team{
    char name[15];//队名 
    int num;//解决题数 
    int pen;//罚时 
}t[100005];

int cmp(team x,team y)
{
    if(x.num==y.num)
        return x.pen<y.pen;
    else
        return x.num>y.num;
}

int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        int n,d;
        scanf("%d%d",&n,&d);
        for(int i=0;i<n;i++)
        {
            scanf("%s%d%d",&t[i].name,&t[i].num,&t[i].pen);
        }
        sort(t,t+n,cmp);//排序 
        double m=double(d)*0.1*double(n);
        if(int(m*10)%10==5)//如果小数是0.5 
        {
            printf("%s\n",t[int(m)].name);
        }
        else
        {
            printf("Quailty is very great\n");
        }
    }
    return 0;
}

 

标签:gold,number,CCPC,team,teams,medal,Quailty
来源: https://blog.csdn.net/qq_44866969/article/details/99588671

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有