Submission #856430

#TimeUsernameProblemLanguageResultExecution timeMemory
856430overwatch9Sails (IOI07_sails)C++17
40 / 100
1073 ms2884 KiB
#include <iostream> #include <vector> #include <queue> #include <algorithm> using namespace std; using ll = long long; int main() { int n; cin >> n; vector <pair <int, int>> updates(n); for (int i = 0; i < n; i++) { cin >> updates[i].first >> updates[i].second; } sort(updates.begin(), updates.end()); ll ans = 0; priority_queue <ll> pq; for (int i = 0; i < n; i++) { if (i == 0) { for (int j = 1; j <= updates[i].first; j++) pq.push(0); } else { for (int j = updates[i-1].first+1; j <= updates[i].first; j++) pq.push(0); } vector <ll> to_add(updates[i].second); for (int j = 0; j < updates[i].second; j++) { ll x = pq.top(); pq.pop(); ans += (-x); to_add[j] = x - 1; } for (auto i : to_add) pq.push(i); } 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...