Submission #1019642

#TimeUsernameProblemLanguageResultExecution timeMemory
1019642overwatch9Sure Bet (CEOI17_sure)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; using dbl = double; int main() { int n; cin >> n; vector <pair <dbl, dbl>> nums(n); for (int i = 0; i < n; i++) cin >> nums[i].first >> nums[i].second; vector <dbl> a(n), b(n); for (int i = 0; i < n; i++) { a[i] = nums[i].first; b[i] = nums[i].second; } sort(a.begin(), a.end()); sort(b.begin(), b.end()); dbl l = a.back(), r = b.back(); dbl ans = max((dbl)0, min(l, r) - (dbl)2); for (int cnt = 4, pt = n-2; cnt <= n*2; cnt += 2, pt--) { if (r - l > 0.000000001) l += a[pt]; else r += b[pt]; ans = max(ans, min(l, r) - (cnt - 1)); if (r - l > 0.0000000001) r += b[pt]; else l += a[pt]; ans = max(ans, min(l, r) - cnt); } cout << fixed << setprecision(4) << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...