Submission #134472

#TimeUsernameProblemLanguageResultExecution timeMemory
134472dragonslayeritSure Bet (CEOI17_sure)C++14
100 / 100
78 ms3576 KiB
#include <cstdio> #include <algorithm> #include <functional> double as[100005]; double bs[100005]; double all[200005]; int main(){ int N; scanf("%d",&N); for(int i=0;i<N;i++){ scanf("%lf %lf",&as[i],&bs[i]); } std::sort(as,as+N,std::greater<double>()); std::sort(bs,bs+N,std::greater<double>()); int ai=0,bi=0; double again=0,bgain=0; double best=0; while(ai<N||bi<N){ if(bi==N||(ai<N&&again<bgain)){ again+=as[ai++]; }else{ bgain+=bs[bi++]; } best=std::max(best,std::min(again,bgain)-ai-bi); } printf("%.4f\n",best); }

Compilation message (stderr)

sure.cpp: In function 'int main()':
sure.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&N);
   ~~~~~^~~~~~~~~
sure.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lf %lf",&as[i],&bs[i]);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...