Submission #79333

#TimeUsernameProblemLanguageResultExecution timeMemory
79333aminraSure Bet (CEOI17_sure)C++14
100 / 100
236 ms18456 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const int MOD = (int)1e9 + 7; const int MAXN = (int)3e5 + 7; const int infint = (int)1e9; int n; ld a[MAXN], b[MAXN]; ld g(int mid, int ted) { ld c1 = 0; if(mid) c1 = a[mid - 1]; mid = ted - mid; ld c2 = 0; if(mid) c2 = b[mid - 1]; return min(c1, c2); } ld f(int ted) { //jelo tarin i ro mikhaim ke g(i) > g(i - 1) int L = max(0, ted - n), R = ted + 1; while(R - L > 1) { int mid = (R + L) >> 1; if(g(mid, ted) > g(mid - 1, ted)) L = mid; else R = mid; } return g(L, ted); } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (int i = 0; i < n; i++) cin >> a[i] >> b[i]; sort(a, a + n, greater<double> ()); sort(b, b + n, greater<double> ()); for (int i = 1; i < n; i++) a[i] += a[i - 1], b[i] += b[i - 1]; ld ans = 0; for (int i = 1; i <= 2 * n; i++) ans = max(ans, f(i) - i); cout << fixed << setprecision(4) << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...