你准备好了吗?

Problem Description

Is this your first times participating in this kind of contest? I think most of you will answer “Yes”. So let’s do this problem as warm-up and check whether the PC^2 work properly.
Now, we will give you the information of some contests that are just like the one you are taking. Your task is to output their rank lists according to the contest rules you have already understood.

Input

There is only one number C (<=100) in the first line of the input, which is the number of contests.
For each contest, the first line contains only one number N indicating the total number of teams. And then follow N lines. Each line has three numbers Ti, Si and Pi (1<=Ti<=N, 0<=Si<=20, 0<=Pi<=10000), which stand for the ID, Score and Penalty of the ith team of the contest respectively. Specially, all teams’ scores are distinct.

Output

For each contest, you should output the rank list (team ID) in descent order in just one line. Numbers separate exactly one space.

Sample Input

2
3
3 2 200
2 1 100
1 3 300
2
1 2 222
2 1 222

Sample Output

1 3 2
1 2
 
 
#include<iostream>
#include<algorithm>
#include<malloc.h>
using namespace std;
struct  td
{
  int ti;    //  ID
  int si;    //  得分
  int pi;    //  罚分
};

bool cmp(struct td a,struct td b)
{
   if(a.si!=b.si) return a.si>b.si;  //  得分不同时,降序
   else return a.pi<b.pi;            //  相同时,按罚分升序
}
int main()
{
    int c,si,pi,n,i;
    struct td *st;
    while(cin>>c)
    {
        while(c--)
        {
            cin>>n;
            st=(  struct td *)malloc(sizeof(struct td)*n);
            for(i=0;i<n;i++)
            {
                 cin>>st[i].ti;
                 cin>>st[i].si>>st[i].pi;
            
            }
            sort(st,st+n,cmp);   // 排 序
   
          for(i=0;i<n;i++)
             if(i==0)  cout<<st[i].ti;
               else cout<<" "<<st[i].ti;

              if(c!=0)  cout<<endl;    //   每次测试数据的最后一组不用输出换行
            free(st);
        }    
    }
    return 0;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值