1 solutions
-
0
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; if (!(cin >> n)) return 0; struct Person { int a, b, idx; }; vector<Person> v; v.reserve(n); for (int i = 1; i <= n; ++i) { int a, b; cin >> a >> b; v.push_back({a, b, i}); } sort(v.begin(), v.end(), [](const Person &x, const Person &y){ if (x.a != y.a) return x.a > y.a; // higher VIP first if (x.b != y.b) return x.b < y.b; // earlier arrival first return x.idx < y.idx; // smaller index first }); for (int i = 0; i < n; ++i) { if (i) cout << ' '; cout << v[i].idx; } cout << '\n'; return 0; }
Information
- ID
- 7102
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 3
- Tags
- # Submissions
- 76
- Accepted
- 23
- Uploaded By