Submission #40042

#TimeUsernameProblemLanguageResultExecution timeMemory
40042igziSure Bet (CEOI17_sure)C++14
100 / 100
182 ms3580 KiB
#include <bits/stdc++.h> #define maxN 100001 using namespace std; double m=0,a[maxN],b[maxN],x,y; bool poredi(float a,float b){ return a>b; } int main() { long long n,i,j; x=y=0; cin>>n; for(i=0;i<n;i++){ cin>>a[i]>>b[i]; } sort(a,a+n,poredi); sort(b,b+n,poredi); i=j=0; while(i<n){ x+=a[i]; i++; while(j<n && y<x){ if(m<min(x,y)-i-j) m=min(x,y)-i-j; y+=b[j]; j++; } if(m<min(x,y)-i-j) m=min(x,y)-i-j; } cout<<fixed<<setprecision(4)<<m<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...