Submission #747185

#TimeUsernameProblemLanguageResultExecution timeMemory
747185anaduguleanuSure Bet (CEOI17_sure)C++14
100 / 100
184 ms3668 KiB
#include <iostream> #include <algorithm> #include <iomanip> #define MAX 100000 using namespace std; ///ifstream cin ("c.in"); ///ofstream cout ("c.out"); double a[MAX + 10], b[MAX + 10]; bool cmp(double x, double y) { return (x > y); } int main() { int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i] >> b[i]; sort(a + 1, a + n + 1, cmp); sort(b + 1, b + n + 1, cmp); int nA = 1, nB = 1; double A = 0, B = 0, ans = 0; for (int i = 1; i <= 2 * n; i++) { if (nA <= n && (nB == n + 1 || A < B)) { A = A + a[nA]; nA++; } else { B = B + b[nB]; nB++; } ans = max(ans, min(A, B) - i); } cout << fixed << setprecision(4) << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...