Submission #1052634

#TimeUsernameProblemLanguageResultExecution timeMemory
1052634VMaksimoski008Sure Bet (CEOI17_sure)C++17
100 / 100
87 ms1996 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<double> a(n), b(n); for(int i=0; i<n; i++) cin >> a[i] >> b[i]; sort(a.rbegin(), a.rend()); sort(b.rbegin(), b.rend()); for(int i=1; i<n; i++) b[i] += b[i-1]; double l=0, r=1e9, ans=0; while(r - l > 1e-6) { double mid = (l + r) / 2, sum1 = 0; bool ok = 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(b[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...