Submission #1052633

#TimeUsernameProblemLanguageResultExecution timeMemory
1052633VMaksimoski008Sure Bet (CEOI17_sure)C++17
100 / 100
75 ms2780 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<double> a(n), b(n), pref(n); for(int i=0; i<n; i++) cin >> a[i] >> b[i]; sort(a.rbegin(), a.rend()); sort(b.rbegin(), b.rend()); pref[0] = b[0]; for(int i=1; i<n; i++) pref[i] = pref[i-1] + b[i]; double l=0, r=1e9, ans=0; while(r - l > 1e-6) { double mid = (l + r) / 2; bool ok = 0; double sum1 = 0; for(int i=0; i<n&&!ok; i++) { sum1 += a[i]; if(sum1 - i - 2 < mid) continue; int mx = min(n-1, (int)((sum1 - i - 2) - mid)); if(pref[mx] - mx - i - 2 >= mid && sum1 - i - 2 - mx >= mid) ok = 1; } if(ok) ans = l = mid; else r = mid; } cout << setprecision(4) << fixed << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...