Submission #698086

#TimeUsernameProblemLanguageResultExecution timeMemory
698086qwerasdfzxclRoller Coaster Railroad (IOI16_railroad)C++17
0 / 100
2068 ms12204 KiB
#include "railroad.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; pair<int, int> a[200200]; int n; long long plan_roller_coaster(std::vector<int> S, std::vector<int> T) { n = S.size(); priority_queue<pair<int, int>> pq1, pq2; for (int i=1;i<=n;i++){ a[i] = {S[i-1], T[i-1]}; pq1.emplace(a[i].first, i); pq2.emplace(a[i].second, i); } while(pq2.size() > 1){ auto [e, i] = pq2.top(); pq2.pop(); auto [s, j] = pq1.top(); if (i==j){ auto p = pq1.top(); pq1.pop(); auto [ss, jj] = pq1.top(); pq1.pop(); s = ss, j = jj; pq1.push(p); } else pq1.pop(); if (s < e) return 1e18; a[i] = {a[i].first, a[j].second}; pq1.emplace(a[i].first, i); pq2.emplace(a[i].second, i); } 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...