#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";
}*/
컴파일 시 표준 에러 (stderr) 메시지
railroad.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
railroad_c.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
# | 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... |