Submission #773296

#TimeUsernameProblemLanguageResultExecution timeMemory
773296rominanafuSails (IOI07_sails)C++11
40 / 100
1077 ms1968 KiB
#include <bits/stdc++.h> #define pii pair<int,int> using namespace std; typedef long long ll; struct ura { int h, k; }; int n; int max_alt; ura masts[100005]; int alturas[100005]; ll resp; priority_queue<int> q; bool cmp(ura &a, ura &b) { return a.h < b.h; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for(int i=0; i<n; i++) { cin >> masts[i].h >> masts[i].k; } sort(masts, masts+n, cmp); vector<int> add; int a; for(int i=0; i<n; i++) { while (!add.empty()) { q.push(add.back()); add.pop_back(); } while (max_alt < masts[i].h) { q.push(0); max_alt++; } while (masts[i].k--) { a = q.top(); q.pop(); add.push_back(a-1); resp += a * -1; } } cout << resp; 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...