| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1244384 | SpyrosAliv | Roller Coaster Railroad (IOI16_railroad) | C++20 | 76 ms | 6756 KiB |
#include "railroad.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll INF = 1e17;
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> maxT, maxS;
int n = s.size();
for (int i = 0; i < n; i++) {
maxT.push({t[i], i});
maxS.push({s[i], i});
}
vector<bool> taken(n, false);
for (int i = 0; i < n-1; i++) {
while (!maxT.empty() && taken[maxT.top().second]) {
maxT.pop();
}
while (!maxS.empty() && taken[maxS.top().second]) {
maxS.pop();
}
int cand1 = maxT.top().second;
int cand2 = maxS.top().second;
if (t[cand1] <= s[cand2]) {
taken[cand1] = true;
continue;
}
// must take cand2
taken[cand2] = true;
while (!maxS.empty() && taken[maxS.top().second]) {
maxS.pop();
}
int cand3 = maxS.top().second;
if (t[cand2] > s[cand3]) return 1;
}
return 0;
}
/*
int main() {
int n; cin >> n;
vector<int> s(n), t(n);
for (auto &i: s) cin >> i;
for (auto &i: t) cin >> i;
cout << plan_roller_coaster(s, t) << "\n";
}*/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... | ||||
