Submission #213055

#TimeUsernameProblemLanguageResultExecution timeMemory
213055tatyamSails (IOI07_sails)C++17
100 / 100
131 ms5624 KiB
#include <bits/stdc++.h> using namespace std; #define each(i,a) for(auto&& i : a) int main(){ int n; cin >> n; vector<pair<int, int>> a(n); each(i, a) cin >> i.first >> i.second; sort(a.begin(), a.end()); multiset<int> X; X.insert(0); each(i, a){ auto [h, k] = i; X.insert(h); auto p = X.upper_bound(h - k), q = prev(p); int next = *q + *p - h + k; if(q != X.begin()) X.erase(q); X.insert(next); X.erase(p); } long ans = 0, cnt = 0; for(auto p = X.end(); p-- != X.begin(); cnt++) ans += cnt * *p; cout << ans << endl; }
#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...