Submission #1027536

#TimeUsernameProblemLanguageResultExecution timeMemory
1027536vjudge1Sure Bet (CEOI17_sure)C++17
0 / 100
1 ms4444 KiB
#include <bits/stdc++.h> using namespace std; #define ld long double const int N = 1e5+5; int n; ld a[N], b[N], sufB[N]; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(10); cin >> n; for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; } sort(a, a+n); sort(b, b+n); sufB[n] = 0; for (int i = n-1; i >= 0; i--) { sufB[i] = sufB[i+1] + b[i]; } ld ans = 0; ld sumA = 0; for (int i = n-1; i >= 0; i--) { sumA += a[i]; int l = 0; int r = n-1; while (l < r) { int mid = (l+r) >> 1; if (min(sumA, sufB[mid]) - 1 > min(sumA, sufB[mid+1])) r = mid; else l = mid+1; } ans = max(ans, min(sumA, sufB[l]) - (n-i) - (n-l)); } cout << ans << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...