2019杭电多校 第八场 1010 Quailty and CCPC(结构体排序)

2019杭电多校 第八场 1010 Quailty and CCPC(结构体排序)

题目

http://acm.hdu.edu.cn/showproblem.php?pid=6666

题意

给你n d两个数,表示n支队伍比赛金牌取前百分之10d。
后面n行给你队伍名和过题数和罚时。问有没有队伍卡在差0.5位金牌的。

题解

直接结构体排序一下,判断一下存不存在这样的队伍就好了。

代码

#include<bits/stdc++.h>
using namespace std;
char name[100005][30];
long long sc[100005],fa[100005];
struct Team{
    char name[50];
    int score;
    int tim;
}team[100005];
int cmp(Team a,Team b)
{
    if(a.score != b.score)
        return a.score > b.score;
    else
        return a.tim < b.tim;
}
int main()
{
    int t,n,d;
    while(~scanf("%d",&t))
	{
        while(t--)
		{
            scanf("%d %d",&n,&d);
            for(int i = 0;i < n;i++)
			{
                scanf("%s %d %d",team[i].name,&team[i].score,&team[i].tim);
            }
            if(n * d % 10 != 5)
                printf("Quailty is very great\n");
            else
			{
				sort(team,team+n,cmp);
                printf("%s\n",team[n * d / 10].name);
            }
        }
    }
}
发布了51 篇原创文章 · 获赞 16 · 访问量 3367

猜你喜欢

转载自blog.csdn.net/weixin_43911945/article/details/99618394