| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1286225 | LaMatematica14 | Roller Coaster Railroad (IOI16_railroad) | C++20 | 58 ms | 6596 KiB |
#include "railroad.h"
#include <bits/stdc++.h>
using namespace std;
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
int n = (int) s.size();
vector<pair<int, int>> s_ord(n), t_ord(n);
for (int i = 0; i < n; i++) s_ord[i] = {s[i], i};
for (int i = 0; i < n; i++) t_ord[i] = {t[i], i};
sort(s_ord.rbegin(), s_ord.rend());
sort(t_ord.rbegin(), t_ord.rend());
int j = 0;
bool sec = 0, has_sp = 0;
for (int i = 0; i < n; i++) {
while (j < n && s_ord[j].first >= t_ord[i].first) j++;
int uni = j;
if (t_ord[i].first <= s[t_ord[i].second]) {
if (i == 0) uni--;
else if (s[t_ord[i].second] < t_ord[i-1].first) uni--;
}
if (has_sp) {
uni++;
if ((sec && j > n-2) || (j > n-1)) uni--;
}
if (uni < i+1) {
assert(uni == i);
if (has_sp) return 1;
if (i == 0 && t_ord[i].second == s_ord[n-1].second) sec = 1;
has_sp = 1;
i--; // redo
}
}
return 0;
}
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... | ||||
