53 lines
1.1 KiB
C++
53 lines
1.1 KiB
C++
#include<bits/stdc++.h>
|
|
using namespace std;
|
|
|
|
struct patient {
|
|
string id;
|
|
int year;
|
|
};
|
|
|
|
int main() {
|
|
int n;
|
|
cin >> n;
|
|
|
|
int num = 0, cnt = 0;
|
|
patient p[n];
|
|
patient x[n];
|
|
string young[n];
|
|
for (int i = 0; i < n; i++) {
|
|
cin >> p[i].id >> p[i].year;
|
|
x[i].id = p[i].id;
|
|
x[i].year = p[i].year;
|
|
}
|
|
|
|
for (int j = 0; j < n; j++) {
|
|
if (p[j].year >= 60)
|
|
num++;
|
|
else
|
|
young[cnt] = p[j].id;
|
|
cnt++;
|
|
}
|
|
|
|
for (int i = 0; i < n - 1; i++)
|
|
for (int j = 0; j < n - 1 - i; j++) {
|
|
int temp_year;
|
|
string temp_id;
|
|
if (x[j].year < x[j + 1].year) {
|
|
temp_year = x[j].year;
|
|
temp_id = x[j].id;
|
|
x[j].year = x[j + 1].year;
|
|
x[j].id = x[j + 1].id;
|
|
x[j + 1].year = temp_year;
|
|
x[j + 1].id = temp_id;
|
|
}
|
|
}
|
|
|
|
for (int i = 0; i < num; i++) {
|
|
cout << x[i].id << endl;
|
|
}
|
|
for (int j = 0; j < cnt; j++) {
|
|
cout << young[j] << endl;
|
|
}
|
|
return 0;
|
|
}
|