답안 #753284

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
753284 2023-06-05T02:32:05 Z acceptify 쌀 창고 (IOI11_ricehub) C++17
68 / 100
13 ms 2508 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), calc(i, i + mid - 1, p + 1)});
        }
        if (cost <= B) l = mid + 1, res = mid;
        else r = mid - 1;
    }
    return res;
}
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 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 0 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 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 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 1 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 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 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 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 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 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 596 KB Output is correct
2 Correct 4 ms 512 KB Output is correct
3 Correct 12 ms 1420 KB Output is correct
4 Correct 12 ms 2508 KB Output is correct
5 Correct 11 ms 1236 KB Output is correct
6 Correct 10 ms 1216 KB Output is correct
7 Correct 11 ms 2124 KB Output is correct
8 Correct 11 ms 2260 KB Output is correct
9 Correct 9 ms 1096 KB Output is correct
10 Correct 9 ms 1160 KB Output is correct
11 Correct 12 ms 2508 KB Output is correct
12 Incorrect 13 ms 2440 KB Output isn't correct
13 Halted 0 ms 0 KB -