Submission #113605

#TimeUsernameProblemLanguageResultExecution timeMemory
113605VardanyanSure Bet (CEOI17_sure)C++14
100 / 100
96 ms5352 KiB
#include <bits/stdc++.h> using namespace std; const int N = 100*1000+5; pair<double,double> a[N]; double prefa[N],prefb[N]; int main() { ios_base::sync_with_stdio(false); int n; cin>>n; for(int i = 1;i<=n;i++) cin>>a[i].first>>a[i].second; sort(a+1,a+1+n); reverse(a+1,a+1+n); for(int i = 1;i<=n;i++) prefa[i] = prefa[i-1]+a[i].first; for(int i = 1;i<=n;i++) swap(a[i].first,a[i].second); sort(a+1,a+1+n); reverse(a+1,a+1+n); for(int i = 1;i<=n;i++) prefb[i] = prefb[i-1]+a[i].first; double ans = 0; int i = 0; int j = 0; double x,y; x = y = 0; while(1){ // cout<<i<<" "<<j<<endl; if(i!=n){ i++; x = prefa[i]; ans = max(ans,min(x,y)-(i+j)); } while(x<=y){ if(i == n) break; i++; x=prefa[i]; ans = max(ans,min(x,y)-(i+j)); } ans = max(ans,min(x,y)-(i+j)); if(j!=n){ j++; y = prefb[j]; ans = max(ans,min(x,y)-(i+j)); } while(y<=x){ if(j == n) break; j++; y=prefb[j]; ans = max(ans,min(x,y)-(i+j)); } ans = max(ans,min(x,y)-(i+j)); if(i == n && j == n) break; } printf("%.4lf",(double)ans); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...