Submission #722565

#TimeUsernameProblemLanguageResultExecution timeMemory
722565ymmRoller Coaster Railroad (IOI16_railroad)C++17
0 / 100
253 ms12836 KiB
#include "railroad.h" #include <bits/stdc++.h> #define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x) #define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x) typedef long long ll; typedef std::pair<int, int> pii; typedef std::pair<ll , ll > pll; using namespace std; long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { s.push_back(1e9+10); t.push_back(1); int n = s.size(); set<pii> S; Loop (i,0,n) S.insert({s[i], i}); ll ans = 0; int p = 1; while (S.size()) { auto it = S.lower_bound(pii{p, INT_MIN}); if (it == S.end()) --it; int i = it->second; ans += max(0, p - s[i]); p = t[i]; S.erase(it); } ans += p-1; return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...