# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
412437 |
2021-05-26T21:44:02 Z |
Dakto |
Sails (IOI07_sails) |
C++17 |
|
74 ms |
4060 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+=nv[i];
long long d=min(min(v,cnt[i]),c-(s-ts-i*(c-1)<=0?1:0));
tr+=d*(d-1)/2;
ts+=d;
v-=d;
}
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 |
Correct |
10 ms |
2636 KB |
Output is correct |
2 |
Correct |
11 ms |
2656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
2640 KB |
Output is correct |
2 |
Correct |
11 ms |
2636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
2660 KB |
Output is correct |
2 |
Correct |
11 ms |
2636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
2664 KB |
Output is correct |
2 |
Correct |
11 ms |
2664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
2664 KB |
Output is correct |
2 |
Correct |
11 ms |
2636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
2712 KB |
Output is correct |
2 |
Correct |
27 ms |
2840 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
2884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
46 ms |
3028 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
65 ms |
3172 KB |
Output is correct |
2 |
Correct |
60 ms |
4060 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
68 ms |
3300 KB |
Output is correct |
2 |
Correct |
57 ms |
3996 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
74 ms |
3364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |