Start: Jan, 04, 2017 19:40:00
2016年秋季学期程序设计基础期末考试
End: Jan, 04, 2017 21:40:00
Time elapsed:
Time remaining:

Problem_ID: D
Result: Accepted
Time: 563ms
Memory: 1724kB
Author: fyk19980409
In contest: 1084

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long ll;
struct node
{
	char nam[100];
	int c;
}cord[100];
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		for(int i=0;i<n;i++)
		{
			int c1,c2;
			cin>>cord[i].nam;
			cin>>c1>>c2;
			cord[i].c=c1+c2;
		}
		for(int i=0;i<n;i++)
		{
			for(int j=i;j<n;j++)
			{
				node t;
				if(cord[i].c<cord[j].c)
				{
					t=cord[i];
					cord[i]=cord[j];
					cord[j]=t;
				}
			}
		}
		for(int i=0;i<n;i++)
		{
			cout<<cord[i].nam<<endl;
		}
	}
	
	
}