Submission #856407

#TimeUsernameProblemLanguageResultExecution timeMemory
856407overwatch9Sails (IOI07_sails)C++17
30 / 100
1065 ms7024 KiB
#include <iostream> #include <vector> #include <queue> #include <algorithm> using namespace std; using ll = long long; int main() { int n; cin >> n; priority_queue <pair <ll, int>> pq; vector <pair <int, int>> updates(n); int maxh = 0; for (int i = 0; i < n; i++) { cin >> updates[i].first >> updates[i].second; maxh = max(maxh, updates[i].first); } for (int i = 1; i <= maxh; i++) pq.push({0, i}); sort(updates.begin(), updates.end()); ll ans = 0; for (int i = 0; i < n; i++) { priority_queue <pair <ll, int>> tp; int done = 0; while (done < updates[i].second) { pair <ll, int> x = pq.top(); pq.pop(); if (x.second <= updates[i].first) { ans += (-x.first); tp.push({x.first-1, x.second}); done++; } else { tp.push(x); } } while (!tp.empty()) { pq.push(tp.top()); tp.pop(); } } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...