Submission #137076

#TimeUsernameProblemLanguageResultExecution timeMemory
137076thebesSure Bet (CEOI17_sure)C++14
100 / 100
102 ms3576 KiB
#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)

sure.cpp: In function 'int main()':
sure.cpp:10:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(scanf("%d",&n),i=1;i<=n;i++){
         ~~~~~~~~~~~~~~^~~~
sure.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lf%lf",&a[i],&b[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...