Submission #991038

# Submission time Handle Problem Language Result Execution time Memory
991038 2024-06-01T06:32:40 Z stdfloat Rice Hub (IOI11_ricehub) C++17
100 / 100
19 ms 4444 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;

using ll = long long;

int besthub(int n, int L, int X[], ll B) {
    vector<ll> p(n);
    for (int i = 0; i < n; i++)
        p[i] = (i ? p[i - 1] : 0) + X[i];

    int mx = 0;
    for (int i = 0; i < n; i++) {
        int l = i, r = n - 1;
        while (l <= r) {
            int md = (l + r) >> 1;

            bool tr = ((i & 1) != (md & 1));
            int x = (md - i) >> 1, y = (tr ? (X[i + x] + X[i + x + 1]) >> 1 : X[i + x]);
            if ((ll)(x + 1) * y - p[i + x] + (i ? p[i - 1] : 0) + p[md] - p[i + x] - (ll)(x + tr) * y <= B) l = md + 1;
            else r = md - 1;
        }

        mx = max(mx, l - i);
    }

    return mx;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 504 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 436 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 416 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 600 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 604 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 17 ms 3420 KB Output is correct
4 Correct 17 ms 4440 KB Output is correct
5 Correct 8 ms 3164 KB Output is correct
6 Correct 8 ms 3164 KB Output is correct
7 Correct 19 ms 4188 KB Output is correct
8 Correct 16 ms 4188 KB Output is correct
9 Correct 8 ms 3164 KB Output is correct
10 Correct 8 ms 3148 KB Output is correct
11 Correct 17 ms 4444 KB Output is correct
12 Correct 17 ms 4440 KB Output is correct
13 Correct 8 ms 3276 KB Output is correct
14 Correct 8 ms 3420 KB Output is correct
15 Correct 18 ms 3848 KB Output is correct
16 Correct 13 ms 3932 KB Output is correct
17 Correct 15 ms 4328 KB Output is correct
18 Correct 15 ms 4328 KB Output is correct
19 Correct 16 ms 4188 KB Output is correct
20 Correct 16 ms 4188 KB Output is correct