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"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define popcnt __builtin_popcount
#define mp make_pair
pii a[200100];
long long plan_roller_coaster(vector<int> s, vector<int> t) {
int n = s.size();
multiset<pii> l, r;
for(int i=0; i<n; i++){
l.insert({s[i], t[i]});
r.insert({t[i], s[i]});
}
while(l.size() > 1){
pii x = *l.begin();
auto it = r.lower_bound(mp(x.ff,1e18));
if(it == r.begin()) return 1;
it--;
pii y = *it;
y = mp(y.ss, y.ff);
if(y == x){
if(it == r.begin()) return 1;
it--;
y = *it;
y = mp(y.ss, y.ff);
}
r.erase(it);
r.erase(r.find(mp(x.ss, x.ff)));
l.erase(l.begin());
l.erase(l.find(y));
l.insert({y.ff, x.ss});
r.insert({x.ss, y.ff});
}
return 0;
}
# | 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... |