# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1069637 | Ignut | Roller Coaster Railroad (IOI16_railroad) | C++17 | 183 ms | 25812 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Ignut
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18 + 123;
const int inf = 1e9 + 123;
ll plan_roller_coaster(vector<int> s, vector<int> t) {
int n = s.size();
multiset<pair<int, int>> ms;
for (int i = 0; i < n; i ++) ms.insert({s[i], -t[i]});
int speed = 1;
int se = -1, te = -1;
for (int i = 0; i < n; i ++) {
auto it = ms.lower_bound({speed, -inf});
if (it == ms.end())
return 1;
auto [S, T] = *it;
ms.erase(it);
speed = -T;
if (i == n - 1) continue;
if (ms.lower_bound({speed, -inf}) == ms.end()) {
se = S, te = -T;
it ++;
if (it == ms.end())
return 1ll;
auto [SS, TT] = *it;
speed = -TT;
// ms.insert({S, T});
ms.erase(it);
// cout << "bad " << S << ' ' << -T << '\n';
// cout << "get2 " << SS << ' ' << -TT << '\n';
}
else {
// cout << "get " << S << ' ' << -T << '\n';
}
}
if (se == -1 || se >= speed)
return 0ll;
else
return 1ll;
}
/*
4
13 11
20 16
7 7
13 18
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |