Result: Accepted
Time: 721ms
Memory: 1716kB
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string.h>
using namespace std;
struct stu {
int total;
string name;
}a[200];
int cmp(const void *a, const void *b) {
return (*(struct stu *)b).total - (*(struct stu *)a).total;
}
int main() {
int n, tempmark1, tempmark2, t;
cin >> t;
while (t--) {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i].name >> tempmark1 >> tempmark2;
a[i].total = tempmark1 + tempmark2;
}
qsort(a, n, sizeof(struct stu), cmp);
for (int i = 0; i < n; i++) {
cout << a[i].name << endl;
}
}
}