제출 #923499

#제출 시각아이디문제언어결과실행 시간메모리
923499Andrei_ierdnASure Bet (CEOI17_sure)C++17
100 / 100
70 ms3724 KiB
#include <iostream> #include <iomanip> #include <cmath> #include <algorithm> using namespace std; long long n, i, j, cnt; long long a[100010], b[100010], suma, sumb, ans = 0; long double x; bool descCmp(long long x, long long 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 (i == n+1 || (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...