Submission #742157

#TimeUsernameProblemLanguageResultExecution timeMemory
742157iulia13Sure Bet (CEOI17_sure)C++14
100 / 100
149 ms3592 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; double a[N], b[N]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i] >> b[i]; a[i] -= 1.0; b[i] -= 1.0; } sort(a + 1, a + n + 1); reverse(a + 1, a + n + 1); sort(b + 1, b + n + 1); reverse(b + 1, b + n + 1); int j = 1; double sa = 0, sb = 0, ans = 0, now; for (int i = 1; i <= n; i++) { sa += a[i]; sb -= 1.0; now = min(sa, sb); ans = max(ans, now); int jj = j; while (jj <= n) { if (min(sa - 1.0, sb + b[jj]) > now) { sa -= 1.0; sb += b[jj]; now = min(sa, sb); jj++; } else break; } ans = max(ans, now); j = jj; } cout << fixed << setprecision(4) << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...