【題目敘述】https://atcoder.jp/contests/abc128/tasks/abc128_b
【Tag】字串、struct、排序
#include <iostream>
#include <algorithm>
using namespace std;
struct restaurant {
int id;
string city;
int score;
bool operator < (const restaurant & b) const {
if (city == b.city) {
return score > b.score;
} else {
return city < b.city;
}
}
};
int main() {
int N;
cin >> N;
restaurant a[N];
for (int i = 0; i < N; i++) {
cin >> a[i].city >> a[i].score;
a[i].id = i + 1;
}
sort(a, a + N);
for (auto i : a) {
cout << i.id << "\n";
}
return 0;
}