Submission #753285

# Submission time Handle Problem Language Result Execution time Memory
753285 2023-06-05T02:35:45 Z acceptify Rice Hub (IOI11_ricehub) C++17
68 / 100
15 ms 1472 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;

int besthub(int R, int L, int X[], long long B){
    long long ps[R];
    for (int i = 0; i < R; i++) ps[i] = X[i] + (i ? ps[i - 1] : 0);
    auto calc = [&] (int l, int r, int p) -> long long {
        long long sum = 0;
        sum += X[p] * (p - l + 1) - ps[p] + (l ? ps[l - 1] : 0);
        sum += ps[r] - ps[p] - X[p] * (r - p);
        return sum;
    };
    int l = 0, r = R, res = 0;
    while (l <= r) {
        int mid = (l + r) / 2;
        long long cost = 1e18;
        for (int i = 0; i + mid - 1 < R; i++) {
            int p = (i + i + mid - 1) / 2;
            cost = min(cost, calc(i, i + mid - 1, p));
            if ((i + i + mid - 1) % 2) cost = min(cost, calc(i, i + mid - 1, p + 1));
        }
        if (cost <= B) l = mid + 1, res = mid;
        else r = mid - 1;
    }
    return res;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 536 KB Output is correct
2 Correct 3 ms 468 KB Output is correct
3 Correct 11 ms 1364 KB Output is correct
4 Correct 11 ms 1472 KB Output is correct
5 Correct 8 ms 852 KB Output is correct
6 Correct 8 ms 892 KB Output is correct
7 Correct 15 ms 1384 KB Output is correct
8 Correct 10 ms 1364 KB Output is correct
9 Correct 11 ms 852 KB Output is correct
10 Correct 8 ms 776 KB Output is correct
11 Correct 11 ms 1364 KB Output is correct
12 Incorrect 11 ms 1364 KB Output isn't correct
13 Halted 0 ms 0 KB -