# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
519637 |
2022-01-26T20:51:31 Z |
sofapuden |
Sails (IOI07_sails) |
C++14 |
|
1000 ms |
1348 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});
sort(v.begin(),v.end());
int cn = -2;
for(int i = 0; i < n; ++i){
int z = v[i].second;
int mx = v[i].first;
auto it = prev(S.end());
vector<pair<int,int>> del, add;
bool ok = 0;
while(z){
if((*it).first == 1)ok = 1;
del.push_back(*it);
int am = min(z,mx-(*it).first+1);
z-=am;
add.push_back({(*it).first+am,(*it).second});
mx = (*it).first-1;
it = prev(it);
}
for(auto x : del)S.erase(x);
for(auto x : add)S.insert(x);
if(ok){
S.insert({1,cn--});
}
}
long long ans = 0;
for(auto x : S){
ans += -1ll * (x.first-1) * (x.second+1);
}
cout << ans << '\n';
}
# |
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 |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
16 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
142 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1078 ms |
540 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1094 ms |
896 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1082 ms |
992 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1068 ms |
1104 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1083 ms |
1348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1081 ms |
1276 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |