# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
868391 | 2023-10-31T10:44:42 Z | lovrot | Sure Bet (CEOI17_sure) | C++17 | 72 ms | 5208 KB |
#include <algorithm> #include <cstdio> #include <vector> using namespace std; typedef long double ld; const int N = 1e5 + 10; int n; ld A[N], B[N]; ld solve() { ld ret = 0, sum = 0, _sum = 0; for(int i = 0, j = 0; i < n; ++i) { sum += A[i]; for(; j < n && _sum < sum; ++j) _sum += B[j]; if(j == n && _sum < sum) break; ret = max(ret, sum - (ld) i - (ld) j - 1.0); } return ret; } int main() { scanf("%d", &n); for(int i = 0; i < n; ++i) scanf("%LF%LF", A + i, B + i); sort(A, A + n, [](ld a, ld b) { return a > b; }); sort(B, B + n, [](ld a, ld b) { return a > b; }); ld ans = solve(); swap(A, B); ans = max(ans, solve()); printf("%.4lf\n", (double) ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3420 KB | Output is correct |
2 | Correct | 2 ms | 3420 KB | Output is correct |
3 | Correct | 2 ms | 3420 KB | Output is correct |
4 | Correct | 2 ms | 3420 KB | Output is correct |
5 | Correct | 2 ms | 3420 KB | Output is correct |
6 | Correct | 2 ms | 3420 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3420 KB | Output is correct |
2 | Correct | 2 ms | 3420 KB | Output is correct |
3 | Correct | 2 ms | 3420 KB | Output is correct |
4 | Correct | 2 ms | 3420 KB | Output is correct |
5 | Correct | 2 ms | 3420 KB | Output is correct |
6 | Correct | 2 ms | 3420 KB | Output is correct |
7 | Correct | 2 ms | 3420 KB | Output is correct |
8 | Correct | 3 ms | 3500 KB | Output is correct |
9 | Correct | 2 ms | 3752 KB | Output is correct |
10 | Correct | 2 ms | 3420 KB | Output is correct |
11 | Correct | 2 ms | 3420 KB | Output is correct |
12 | Correct | 3 ms | 3420 KB | Output is correct |
13 | Correct | 3 ms | 3512 KB | Output is correct |
14 | Correct | 3 ms | 3420 KB | Output is correct |
15 | Correct | 3 ms | 3420 KB | Output is correct |
16 | Correct | 3 ms | 3420 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3420 KB | Output is correct |
2 | Correct | 2 ms | 3420 KB | Output is correct |
3 | Correct | 2 ms | 3420 KB | Output is correct |
4 | Correct | 2 ms | 3420 KB | Output is correct |
5 | Correct | 2 ms | 3420 KB | Output is correct |
6 | Correct | 2 ms | 3420 KB | Output is correct |
7 | Correct | 2 ms | 3420 KB | Output is correct |
8 | Correct | 3 ms | 3500 KB | Output is correct |
9 | Correct | 2 ms | 3752 KB | Output is correct |
10 | Correct | 2 ms | 3420 KB | Output is correct |
11 | Correct | 2 ms | 3420 KB | Output is correct |
12 | Correct | 3 ms | 3420 KB | Output is correct |
13 | Correct | 3 ms | 3512 KB | Output is correct |
14 | Correct | 3 ms | 3420 KB | Output is correct |
15 | Correct | 3 ms | 3420 KB | Output is correct |
16 | Correct | 3 ms | 3420 KB | Output is correct |
17 | Correct | 59 ms | 4668 KB | Output is correct |
18 | Correct | 64 ms | 4668 KB | Output is correct |
19 | Correct | 61 ms | 4764 KB | Output is correct |
20 | Correct | 63 ms | 4944 KB | Output is correct |
21 | Correct | 63 ms | 5208 KB | Output is correct |
22 | Correct | 59 ms | 4760 KB | Output is correct |
23 | Correct | 72 ms | 4896 KB | Output is correct |
24 | Correct | 60 ms | 4700 KB | Output is correct |
25 | Correct | 65 ms | 4944 KB | Output is correct |
26 | Correct | 64 ms | 5180 KB | Output is correct |