Submission #155577

#TimeUsernameProblemLanguageResultExecution timeMemory
155577tevdoreSure Bet (CEOI17_sure)C++14
100 / 100
253 ms2040 KiB
#include<bits/stdc++.h> using namespace std; int n,i,k1,k2; double q1,q2,ans,answer; double a[1000001],b[1000001]; int main(){ cin>>n; for(i=1;i<=n;i++){ cin>>a[i]>>b[i]; } sort(a+1,a+n+1); sort(b+1,b+n+1); k1=n; k2=n; while(true){ ans=min(q1,q2); answer=max(ans,answer); if(q1 >= q2){ if(k2 == 0)break; q2+=b[k2]-1; k2--; q1-=1; continue; } else{ if(k1 == 0)break; q1+=a[k1]-1; k1--; q2-=1; } } printf("%.4lf",(double)answer); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...