| Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|---|
| 441393 | 方相宜 | 【C5-9】病人排队 | C++ | 通过 | 100 | 5 MS | 256 KB | 932 | 2026-05-19 19:28:25 |
#include <iostream> #include <vector> #include <algorithm> using namespace std; struct Patient { string id; int age; int order; }; bool comparePatients(const Patient &a, const Patient &b) { bool aSenior = (a.age >= 60); bool bSenior = (b.age >= 60); if (aSenior && !bSenior) return true; if (!aSenior && bSenior) return false; if (aSenior && bSenior) { if (a.age != b.age) return a.age > b.age; return a.order < b.order; } return a.order < b.order; } int main() { int n; cin >> n; vector<Patient> patients(n); for (int i = 0; i < n; ++i) { cin >> patients[i].id >> patients[i].age; patients[i].order = i; } sort(patients.begin(), patients.end(), comparePatients); for (const auto &p : patients) { cout << p.id << endl; } return 0; }