# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
54482 |
2018-07-03T15:33:35 Z |
Diuven |
Sails (IOI07_sails) |
C++11 |
|
115 ms |
10620 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=100010, inf=2e9;
int n;
pii P[MX];
multiset<int> X;
int main(){
ios::sync_with_stdio(0); cin.tie(0);
cin>>n;
for(int i=1; i<=n; i++) cin>>P[i].first>>P[i].second;
sort(P+1, P+n+1);
for(int i=1; i<=n; i++) X.insert(0);
for(int i=1; i<=n; i++){
int h,cnt; tie(h,cnt)=P[i];
auto itu=X.lower_bound(h-cnt+1);
auto itd=itu; itd--;
if(itu==X.end()){
int tmp=*itd;
X.erase(itd); X.insert(tmp+cnt);
}
else{
cnt-=h-(*itu);
X.erase(itu); X.insert(h);
int tmp=*itd;
X.erase(itd); X.insert(tmp+cnt);
}
}
ll prv=0, ans=0, cnt=n;
for(int x:X){
ans+=(x-prv)*cnt*(cnt-1)/2;
prv=x; cnt--;
}
cout<<ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
492 KB |
Output is correct |
2 |
Correct |
2 ms |
612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
612 KB |
Output is correct |
2 |
Correct |
2 ms |
612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
612 KB |
Output is correct |
2 |
Correct |
2 ms |
612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
692 KB |
Output is correct |
2 |
Correct |
2 ms |
692 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
996 KB |
Output is correct |
2 |
Correct |
26 ms |
2500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
2756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
4384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
71 ms |
6744 KB |
Output is correct |
2 |
Correct |
73 ms |
6972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
81 ms |
8896 KB |
Output is correct |
2 |
Correct |
98 ms |
8896 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
115 ms |
10608 KB |
Output is correct |
2 |
Correct |
108 ms |
10620 KB |
Output is correct |