Submission #43958

#TimeUsernameProblemLanguageResultExecution timeMemory
43958desert97Sure Bet (CEOI17_sure)C++14
100 / 100
284 ms2364 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 1e5+5; double a[MAXN], b[MAXN]; int n; bool check(double x) { int l = n, r = n; double totl = 0, totr = 0; for (int k = 1; k <= 2*n; ++k) { if (totl < k+x) { if (l == 0) break; l--; totl += a[l]; } if (totr < k+x) { if (r == 0) break; r--; totr += b[r]; } if (n-l+n-r <= k) return 1; } return 0; } int main() { cin >> n; for (int i = 0; i < n; ++i) cin >> a[i] >> b[i]; sort(a, a+n); sort(b, b+n); double lo = 0, hi = 1e15; for (int i = 0; i <= 200; ++i) { double mid = (lo+hi)/2; if (check(mid)) lo = mid; else hi = mid; } cout << fixed << setprecision(4) << lo << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...