Submission #293887

#TimeUsernameProblemLanguageResultExecution timeMemory
293887AaronNaiduSails (IOI07_sails)C++14
40 / 100
1095 ms8036 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll n, a, b, finAns; vector<pair<ll, ll> > masts; set<pair<pair<ll, ll>, ll> > numAtHeight; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a >> b; masts.push_back({a, b}); } sort(masts.begin(), masts.end()); finAns = 0; ll prevHeight = 0; ll index = -1; for (auto i : masts) { index++; ll numFlags = i.second; if(i.first > prevHeight) { while (prevHeight < i.first and numFlags > 0) { numAtHeight.insert({{1, prevHeight}, index}); numFlags--; prevHeight++; } } auto it = numAtHeight.begin(); while (numFlags > 0) { auto n = next(it, 1); if (it->second != index) { finAns += it->first.first; numAtHeight.insert({{it->first.first+1, it->first.second}, index}); numAtHeight.erase(it); numFlags--; } it = n; } } cout << finAns << "\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...