# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
213055 |
2020-03-24T20:14:15 Z |
tatyam |
Sails (IOI07_sails) |
C++17 |
|
131 ms |
5624 KB |
#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 time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
384 KB |
Output is correct |
2 |
Correct |
37 ms |
1784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
2296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
65 ms |
2040 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
94 ms |
3576 KB |
Output is correct |
2 |
Correct |
94 ms |
2696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
110 ms |
5624 KB |
Output is correct |
2 |
Correct |
83 ms |
1784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
131 ms |
3448 KB |
Output is correct |
2 |
Correct |
110 ms |
2424 KB |
Output is correct |