Submission #812666

#TimeUsernameProblemLanguageResultExecution timeMemory
812666CookieSure Bet (CEOI17_sure)C++14
0 / 100
1 ms340 KiB
#include<bits/stdc++.h> #include<fstream> using namespace std; //ifstream fin("FEEDING.INP"); //ofstream fout("FEEDING.OUT"); #define sz(a) (int)a.size() #define ll long long #define pb push_back #define forr(i, a, b) for(int i = a; i < b; i++) #define dorr(i, a, b) for(int i = a; i >= b; i--) #define ld long double #define vt vector #include<fstream> #define fi first #define se second #define pll pair<ll, ll> #define pii pair<int, int> const int base = 74; const ll mod = 1e9 + 7, inf = 1e9, mxv = 1005, mxn = 2e5 + 5; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int n; ld a[mxn + 1], b[mxn + 1], pa[mxn + 1], pb[mxn + 1]; ld val(int x, int y){ return(min(pa[x], pb[y]) - (x + y)); } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i] >> b[i]; } ld ans = 0; sort(a + 1, a + n + 1, greater<ld>()); sort(b + 1, b + n + 1, greater<ld>()); for(int i = 1; i <= n; i++){ pa[i] = pa[i - 1] + a[i]; pb[i] = pb[i - 1] + b[i]; } for(int i = 1; i <= 2 * n; i++){ int l = 0, r = min(n, i); while(l <= r){ int m1 = l + (r - l) / 3.0, m2 = r - (r - l) / 3.0; ld v1 = val(m1, i - m1), v2 = val(m2, i - m2); if(v1 < v2){ ans = max(ans, v1); l = m1 + 1; }else{ ans = max(ans, v2); r = m2 - 1; } } } cout << fixed << setprecision(4) << ans; return(0); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...