# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
412431 |
2021-05-26T21:21:18 Z |
Dakto |
Sails (IOI07_sails) |
C++17 |
|
78 ms |
3364 KB |
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
vector<pair<int,int>> v(n);
for(int i=0; i<n; i++) cin>>v[i].first>>v[i].second;
long long res=1e16;
long long s=0;
for(auto i:v) s+=i.second;
vector<long long> da(100000,0), cnt(100050,0), nv(100005,0);
for(auto i:v){
da[i.first]++;
da[i.first-i.second]--;
cnt[i.first]++;
}
for(int i=100000; i>=1; i--){
nv[i]=nv[i+1]+da[i];
cnt[i]+=cnt[i+1];
}
auto check=[&](long long c){
long long v=0;
long long tr=0;
long long ts=0;
for(int i=100000; i>=1; i--){
v+=da[i];
int d=min(min(v,cnt[i]),c-(s-ts<=i?1:0));
tr+=d*(d-1)/2;
v-=d;
ts+=nv[i];
}
if(!v) res=min(res,tr);
return v==0;
};
int l=1, r=1e5;
while(l<r){
int m=(l+r)/2;
if(check(m)) r=m;
else l=m+1;
}
cout<<res<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
2636 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
2636 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
2636 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
2660 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
2636 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
2708 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
31 ms |
2828 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
39 ms |
2992 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
56 ms |
3140 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
66 ms |
3344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
78 ms |
3364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |