| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1323510 | k1r1t0 | Roller Coaster Railroad (IOI16_railroad) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
const int N = 210000;
int n;
vector<array<int, 2>> a;
ll plan_roller_coaster(vi s, vi t) {
n = s.size();
for (int i = 0; i < n; i++)
a.push_back({s[i], t[i]});
vi val;
sort(begin(a), end(a));
for (int i = 0; i < n; i++) {
int pos = lower_bound(begin(a), end(a), {a[i][1], 0}) - begin(a);
val.push_back(n - pos - (a[i][1] <= a[i][0]));
}
sort(begin(val), end(val));
for (int i = 0; i < n; i++)
if (val[i] < i)
return 1;
return 0;
}
#ifdef LOCAL
int main() {
int n;
assert(1 == scanf("%d", &n));
std::vector<int> s(n), t(n);
for (int i = 0; i < n; ++i)
assert(2 == scanf("%d%d", &s[i], &t[i]));
long long ans = plan_roller_coaster(s, t);
printf("%lld\n", ans);
return 0;
}
#endif
