Submission #1020720

#TimeUsernameProblemLanguageResultExecution timeMemory
1020720vjudge1Roller Coaster Railroad (IOI16_railroad)C++17
0 / 100
465 ms22356 KiB
#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.rbegin(); 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(r.find(mp(y.ss, y.ff))); r.erase(r.find(mp(x.ss, x.ff))); l.erase(l.find(x)); l.erase(l.find(y)); l.insert({y.ff, x.ss}); r.insert({x.ss, y.ff}); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...