# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
519648 |
2022-01-26T22:48:15 Z |
sofapuden |
Sails (IOI07_sails) |
C++14 |
|
72 ms |
7388 KB |
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n; cin >> n;
vector<pair<int,int>> v(n);
for(auto &x : v)cin >> x.first >> x.second;
set<pair<int,int>> S;
S.insert({1,1});
S.insert({1,2});
int cn = 3;
sort(v.begin(),v.end());
for(int i = 0; i < n; ++i){
int mx = (*S.rbegin()).first;
int am = min(v[i].first+1,mx+v[i].second)-mx;
if(v[i].second == am){
S.erase(prev(S.end()));
S.insert({mx+am,cn++});
continue;
}
S.insert({mx+am,cn++});
auto it = S.lower_bound({v[i].first-v[i].second+1,0});
if(it == S.begin())it = next(it);
auto it2 = prev(it);
S.insert({(*it2).first+v[i].second-(v[i].first-(*it).first+1),cn++});
S.erase(it);
S.erase(it2);
S.insert({1,cn++});
}
vector<int> v2;
for(auto x : S)v2.push_back(x.first);
reverse(v2.begin(),v2.end());
long long ans = 0;
for(int i = 0; i < v2.size(); ++i){
ans += 1ll * i * (v2[i]-1);
}
cout << ans << '\n';
}
Compilation message
sails.cpp: In function 'int main()':
sails.cpp:42:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
42 | for(int i = 0; i < v2.size(); ++i){
| ~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
716 KB |
Output is correct |
2 |
Correct |
20 ms |
2156 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
2124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
3288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
4884 KB |
Output is correct |
2 |
Correct |
49 ms |
5868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
5792 KB |
Output is correct |
2 |
Correct |
37 ms |
3264 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
6280 KB |
Output is correct |
2 |
Correct |
66 ms |
7388 KB |
Output is correct |