# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1027357 |
2024-07-19T04:06:48 Z |
vjudge1 |
Sure Bet (CEOI17_sure) |
C++17 |
|
60 ms |
2004 KB |
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define taskname ""
using namespace std;
ll n,i,l,r,mid;
double a[100009],b[100009],ans=0.0,ma,ans1,k;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n;
for(i=1;i<=n;i++){
cin>>a[i]>>b[i];
}sort(a+1,a+n+1,greater<>());
sort(b+1,b+n+1,greater<>());
for(i=1;i<=n;i++)
a[i]+=a[i-1];
for(i=1;i<=n;i++)
b[i]+=b[i-1];
for(i=0;i<=n;i++){
ans1=a[i]-i;
l=0;r=n;ma=0.0;
while(l<=r){
mid=(l+r)/2;
k=min(ans1-mid,double(b[mid])-mid-i);
if(k>=ma){
ma=k;
//if(i==3&&mid==1) cout<<k<<"\n";
if(double(b[mid])-mid-i>ans1-mid) r=mid-1;
else if(double(b[mid])-mid-i<ans1-mid) l=mid+1;
else break;
}else{
if(double(b[mid])-mid-i<ans1-mid) l=mid+1;
else r=mid-1;
}
}//if(i==4) cout<<ma;
if(ans<ma) ans=ma;
//cout<<ans<<"\n";
//if(ans==1.1000) cout<<i<<"\n";
}
printf("%.4lf",(double)ans);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
56 ms |
1880 KB |
Output is correct |
18 |
Correct |
54 ms |
2000 KB |
Output is correct |
19 |
Correct |
55 ms |
1884 KB |
Output is correct |
20 |
Correct |
54 ms |
1872 KB |
Output is correct |
21 |
Correct |
58 ms |
1872 KB |
Output is correct |
22 |
Correct |
54 ms |
1792 KB |
Output is correct |
23 |
Correct |
60 ms |
1884 KB |
Output is correct |
24 |
Correct |
55 ms |
1876 KB |
Output is correct |
25 |
Correct |
54 ms |
1980 KB |
Output is correct |
26 |
Correct |
56 ms |
2004 KB |
Output is correct |