제출 #1020745

#제출 시각아이디문제언어결과실행 시간메모리
1020745vjudge1Roller Coaster Railroad (IOI16_railroad)C++17
0 / 100
450 ms26196 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]}); } l.insert({0, 0}); r.insert({0, 0}); l.insert(mp(1e18, 1e18)); r.insert(mp(1e18, 1e18)); while(l.size() > 1){ pii x = *l.rbegin(); auto it = r.lower_bound(mp(x.ff,2e18)); 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...