Submission #66896

#TimeUsernameProblemLanguageResultExecution timeMemory
66896GoogalSure Bet (CEOI17_sure)C++14
100 / 100
118 ms16948 KiB
#include <algorithm> #include <iostream> #include <iomanip> #include <cmath> using namespace std; const int NMAX = 1e5; int n; double res, s1, s2; double a[1 + NMAX]; double b[1 + NMAX]; int main() { ios::sync_with_stdio(false); cin >> n; for(int i = 1; i <= n; i++) cin >> a[i] >> b[i]; sort(a + 1, a + n + 1); sort(b + 1, b + n + 1); int i = n; int j = n; while(i >= 0 && j >= 0) { if(s1 < s2) { s1 += a[i]; i--; } else { s2 += b[j]; j--; } res = max(min(s1, s2) - 2 * n + i + j, res); } cout << setprecision(4) << fixed; cout << res << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...