# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
303024 | 2020-09-19T18:43:40 Z | Kenzo_1114 | Sure Bet (CEOI17_sure) | C++17 | 1 ms | 256 KB |
#include<bits/stdc++.h> using namespace std; const int MAXN = 100010; int n; double a[MAXN], b[MAXN], A, B; int main () { scanf("%d", &n); for(int i = 0; i < n; i++) { scanf("%lf %lf", &A, &B); a[i] = A; b[i] = B; } sort(a, a + n); sort(b, b + n); int ida = n - 1, idb = n - 1; double ans = (int) 0, sa = (int) 0, sb = (int) 0; for(int i = 0; i < n; i++) { if(sa >= sb && 0 <= idb) sb += b[idb], idb--; else if(sa < sb && 0 <= ida) sa += a[ida], ida--; ans = max(ans, min(sa, sb) - i - 1); } printf("%.4lf\n", ans); } /* 4 1.4 3.7 1.2 2 1.6 1.4 1.9 1.5 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Incorrect | 0 ms | 256 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Incorrect | 0 ms | 256 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Incorrect | 0 ms | 256 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |