题目链接:http://ybt.ssoier.cn:8088/problem_show.php?pid=1183
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
const int N = 110;
struct Patient
{
string id;
int age, order;
} p[N];
bool cmp(const Patient &x, const Patient &y)
{
if (x.age >= 60 && y.age >= 60)
{
if (x.age != y.age)
{
return x.age > y.age;
}
else
{
return x.order < y.order;
}
}
else if (x.age >= 60 && y.age < 60)
{
return true;
}
else if (x.age < 60 && y.age >= 60)
{
return false;
}
else
{
return x.order < y.order;
}
}
int main()
{
int n;
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> p[i].id >> p[i].age;
p[i].order = i;
}
sort(p, p + n, cmp);
for (int i = 0; i < n; i++)
{
cout << p[i].id << endl;
}
return 0;
}