2 条题解
-
0
#include <iostream> #include <vector> #include <string> #include <algorithm> using namespace std; int main() { int n; cin >> n; vector<pair<string, int>> students; for (int i = 0; i < n; ++i) { string name; int math, chinese, english, geography; cin >> name >> math >> chinese >> english >> geography; int total_score = math + chinese + english + geography; students.emplace_back(name, total_score); } sort(students.begin(), students.end(), [](const pair<string, int>& a, const pair<string, int>& b) { return a.second > b.second; }); for (int i = 0; i < 3; ++i) { cout << students[i].first << endl; } return 0; }
信息
- ID
- 119
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 5
- 标签
- (无)
- 递交数
- 144
- 已通过
- 53
- 上传者