Submission #44576

#TimeUsernameProblemLanguageResultExecution timeMemory
44576bogdan10bosSure Bet (CEOI17_sure)C++14
100 / 100
208 ms16880 KiB
#include <bits/stdc++.h> using namespace std; //#define FILE_IO int N; double a[100005], b[100005]; int main() { #ifdef FILE_IO freopen("1.in", "r", stdin); freopen("1.out", "w", stdout); #endif cin >> N; for(int i = 1; i <= N; i++) cin >> a[i] >> b[i]; 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 p1 = 1, p2 = 1; double prfA = 0.0, prfB = 0.0; double ans = 0.0; int cnt = 0; while(p1 <= N || p2 <= N) { if(prfA < prfB && p1 <= N) { prfA += a[p1]; p1++; cnt++; } else if(p2 <= N) { prfB += b[p2]; p2++; cnt++; } else break; ans = max(ans, min(prfA, prfB) - cnt); } cout << fixed << setprecision(4) << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...