| Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|---|
| 436403 | 顾鑫辰 | 【C5-9】插入排序 | C++ | 通过 | 100 | 174 MS | 276 KB | 849 | 2026-04-14 16:42:20 |
#include <iostream> #include <vector> #include <algorithm> using namespace std; // 定义学生结构体 struct Student { int grade, time, id; }; // 排序规则 bool cmp(const Student &a, const Student &b) { if (a.grade != b.grade) return a.grade > b.grade; // 分数高的在前 if (a.time != b.time) return a.time < b.time; // 时间少的在前 return a.id < b.id; // 学号小的在前 } int main() { int n; cin >> n; vector<Student> v(n); for (int i = 0; i < n; i++) { cin >> v[i].grade >> v[i].time >> v[i].id; } // 整体排序(包含最后那个漏掉的人) sort(v.begin(), v.end(), cmp); // 输出 for (auto s : v) { cout << s.grade << " " << s.time << " " << s.id << endl; } return 0; }