This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "railroad.h"
//Challenge: Accepted
#include <bits/stdc++.h>
using namespace std;
#ifdef zisk
void debug(){cout << endl;}
template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);}
template<class T> void pary(T l, T r){
while (l != r) cout << *l << " ", l++;
cout << endl;
}
#else
#define debug(...) 0
#define pary(...) 0
#endif
#define ll long long
#define maxn 200005
#define pii pair<int, int>
#define ff first
#define ss second
const ll inf = 1LL<<60;
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
int n = (int) s.size();
set<pii> se, te;
for (int i = 0;i < n;i++) {
se.insert({s[i], i});
te.insert({t[i], i});
}
ll ans = 0;
int cur = 0;
for (int i = 0;i < n;i++) {
if (te.begin()->ff <= se.begin()->ff) {
int ind = te.begin()->ss;
if (cur > s[ind]) ans = 1;
cur = t[ind];
te.erase(te.begin());
se.erase(se.find(make_pair(s[ind], ind)));
} else {
int ind = se.begin()->ss;
if (cur > s[ind]) ans = 1;
cur = t[ind];
se.erase(se.begin());
te.erase(te.find(make_pair(t[ind], ind)));
}
}
return ans;
}
# | 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... |