Gym-100712A-Who Is The Winner

排序一下就好了

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

struct point{
    char str[25];
    int s,p;
};

int cmp(point a, point b)
{
    return a.s>b.s||a.s==b.s&&a.p<b.p;
}


point  a[105];

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {

        int n;
        scanf("%d",&n);
        for(int i=0;i<n;i++)
        {
            getchar();
            scanf("%s",a[i].str);
            scanf("%d%d",&a[i].s,&a[i].p);
        }
        sort(a,a+n,cmp);
        printf("%s\n",a[0].str);
    }
    return 0;
}

你可能感兴趣的:(Gym-100712A-Who Is The Winner)