제출 #570865

#제출 시각아이디문제언어결과실행 시간메모리
570865duytuandao21Sure Bet (CEOI17_sure)C++17
0 / 100
1 ms212 KiB
#include<bits/stdc++.h> #define fi first #define se second using namespace std; const int N = 2e6+7; int n; double a[N], b[N], prefixSumA[N], prefixSumB[N], res = 0; int main() { cin>>n; for(int i=1;i<=n;i++) cin>>a[i]>>b[i]; sort(a+1,a+1+n,greater<double>()); sort(b+1,b+1+n,greater<double>()); for(int i=1;i<=n;i++) { prefixSumA[i] = prefixSumA[i-1] + a[i]; prefixSumB[i] = prefixSumB[i-1] + b[i]; } //for(int i=1;i<=n;i++) cout<<prefixSumA[i]<<" "<<prefixSumB[i]<<'\n'; for(int i=1;i<=2*n;i++) { int l = 0; int r = min(i,n); //double ans = 0; while(l <= r) { int mid = (l+r)/2; double va1 = prefixSumA[mid]; double va2 = prefixSumB[i-mid]; res = max(res, min(va1 - i, va2 - i)); //ans = max(ans, min(va1 - i, va2 - i)); if(va1 - i < va2 - i) l = mid + 1; else r = mid - 1; } //cout<<ans<<" "; } printf("%.4lf",(double)res); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...