Submission #367346

#TimeUsernameProblemLanguageResultExecution timeMemory
367346ijxjdjdSails (IOI07_sails)C++14
40 / 100
1094 ms3048 KiB
#include <bits/stdc++.h> #define FR(i, N) for (int i = 0; i < int(N); i++) #define all(x) begin(x), end(x) using namespace std; using ll = long long; int main() { cin.tie(0); cin.sync_with_stdio(0); int N; cin >> N; vector<pair<int, int>> masts; priority_queue<int, vector<int>, greater<int>> pq; FR(i, N) { int h, k; cin >> h >> k; masts.push_back({h, k}); } sort(all(masts)); // int costs[100000]; int last = 0; ll ans = 0; vector<int> remd; FR(i, N) { remd.clear(); while (last<masts[i].first) { pq.push(0); last++; } while (masts[i].second-->0) { int next = pq.top(); pq.pop(); ans += next; next++; remd.push_back(next); } for (auto& a : remd) { pq.push(a); } } cout << ans << '\n'; 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...
#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...