Submission #1265156

#TimeUsernameProblemLanguageResultExecution timeMemory
1265156JerSure Bet (CEOI17_sure)C++20
60 / 100
6 ms580 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 1005; int n; double a[MAXN], b[MAXN]; double solve(int i){ double pa = 0, pb = 0; int used = 0, inda = 0, indb = 0; while (pa < i and used < i and inda < n) pa += a[inda++], used++; while (pb < i and used < i and indb < n) pb += b[indb++], used++; while (used < i and (inda < n or indb < n)){ if (inda < n and pa < pb) pa += a[inda++]; else pb += b[indb++]; used++; } return min(pa - double(i), pb - double(i)); } int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n; for (int i = 0; i < n; i++) cin >> a[i] >> b[i]; sort(a, a + n, greater<double>()); sort(b, b + n, greater<double>()); double res = 0; for (int i = 0; i <= 2 * n; i++) res = max(res, solve(i)); printf("%.4f\n", res); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...