1 solutions

  • 0
    @ 2025-12-21 17:54:31

    #include #include #include using namespace std; struct Patient { string id; int age; int num; // 登记顺序 }; bool compare(Patient a, Patient b) { if (a.age >= 60 && b.age >= 60) { if (a.age == b.age) return a.num < b.num; return a.age > b.age; } else if (a.age < 60 && b.age < 60) { return a.num < b.num; } else { return a.age > b.age; } } int main() { int n; cin >> n; vector patients(n); for (int i = 0; i < n; ++i) { cin >> patients[i].id >> patients[i].age; patients[i].num = i + 1; } sort(patients.begin(), patients.end(), compare); for (const auto& patient : patients) { cout << patient.id << endl; } return 0; }

    Information

    ID
    1196
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    10
    Tags
    # Submissions
    1
    Accepted
    1
    Uploaded By