Submission #923497

#TimeUsernameProblemLanguageResultExecution timeMemory
923497Andrei_ierdnASure Bet (CEOI17_sure)C++17
60 / 100
77 ms3532 KiB
#include <iostream> #include <iomanip> #include <cmath> #include <algorithm> using namespace std; int n, i, j, cnt; long long a[100010], b[100010], suma, sumb, ans = 0; long double x; bool descCmp(int x, int y) { return x > y; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; for (i = 1; i <= n; i++) { cin >> x; x *= 10000LL; a[i] = round(x); cin >> x; x *= 10000LL; b[i] = round(x); } sort(a+1, a+n+1, descCmp); sort(b+1, b+n+1, descCmp); i = j = 1; for (cnt = 1; cnt <= 2*n; cnt++) { if (j <= n && sumb + b[j] <= suma) { sumb += b[j++]; } else { suma += a[i++]; } ans = max(ans, min(suma, sumb) - 10000LL * cnt); if (i > 1 && j <= n) { ans = max(ans, min(suma - a[i-1], sumb + b[j]) - 10000LL * cnt); } } x = ans; x /= 10000LL; cout << fixed << setprecision(4); cout << x; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...