# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
137076 | thebes | Sure Bet (CEOI17_sure) | C++14 | 102 ms | 3576 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-5;
const int MN = 1e5+5;
double lo, hi, a[MN], b[MN], aa, bb, cc;
int n, i, l, r;
int main(){
for(scanf("%d",&n),i=1;i<=n;i++){
scanf("%lf%lf",&a[i],&b[i]);
}
sort(a+1,a+n+1,[](double i,double j){return i>j;});
sort(b+1,b+n+1,[](double i,double j){return i>j;});
lo=0; hi=2e9;
while(lo+eps<hi){
double m=(lo+hi)/2;
aa=bb=cc=0;
l=r=0;
while(1){
if(aa<m){
if(l==n) break;
aa += a[++l];
aa-=1;
bb-=1;
}
else if(bb<m){
if(r==n) break;
bb += b[++r];
aa-=1;
bb-=1;
}
else break;
}
if(aa>=m&&bb>=m) lo=m+eps;
else hi=m;
}
printf("%.4lf\n",lo);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |