查看题目
#include <bits/stdc++.h>
using namespace std;
struct Stu
{
int id;
int yw, sx, yy;
int score;
} x[310];
bool cmp(Stu a, Stu b)
{
if (a.score > b.score)
return true;
else if (a.score == b.score && a.yw > b.yw)
return true;
else if (a.score == b.score && a.yw == b.yw && a.id < b.id)
return true;
return false;
}
int main()
{
int n, sx, yw, yy;
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> yw >> sx >> yy;
x[i].id = i + 1;
x[i].sx = sx, x[i].yw = yw, x[i].yy = yy;
x[i].score = sx + yw + yy;
}
sort(x, x + n, cmp);
for (int i = 0; i < 5; i++)
{
cout << x[i].id << ' ' << x[i].score << endl;
}
return 0;
}