#include #include #include using namespace std; struct Student { int id; int chinese; int math; int english; int total; } bool compare(const Student &a, const Student &b) { if (a.total != b.total) { return a.total > b.total; } else if (a.chinese != b.chinese) { return a.chinese > b.chinese; } else { return a.id < b.id; } } int main() { int n; cin >> n; vector students(n); for (int i = 0; i < n; ++i) { cin >> students[i].chinese >> students[i].math >> students[i].english; students[i].id = i + 1; students[i].total = students[i].chinese + students[i].math + students[i].english; } sort(students.begin(), students.end(), compare); for (int i = 0; i < 5 && i < n; ++i) { cout << students[i].id << " " << students[i].total << endl; }

return 0;

}

0 条评论

目前还没有评论...

信息

ID
183
时间
ms
内存
MiB
难度
8
标签
递交数
25
已通过
4
上传者