Submission #199668

#TimeUsernameProblemLanguageResultExecution timeMemory
199668algorithm16Sure Bet (CEOI17_sure)C++14
100 / 100
209 ms3952 KiB
#include<iostream> #include<cstdio> #include<vector> #include<algorithm> using namespace std; vector <double> a; vector <double> b; int main() { int n; cin >> n; double maxi=0; for(int i=0;i<n;i++) { double x,y; cin >> x >> y; a.push_back(x); b.push_back(y); } sort(a.begin(),a.end()); sort(b.begin(),b.end()); int inda=n-2,indb=n-2; double suma=a[n-1],sumb=b[n-1]; for(int i=2;i<=n*2;i++) { maxi=max(maxi,min(suma,sumb)-i); if(suma<sumb && inda>=0) { suma+=a[inda]; inda-=1; } else if(indb>=0) { sumb+=b[indb]; indb-=1; } else { suma+=a[inda]; inda-=1; } } maxi=max(maxi,min(suma,sumb)-2*n); printf("%.4lf",maxi); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...