답안 #800679

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
800679 2023-08-01T18:01:21 Z vjudge1 쌀 창고 (IOI11_ricehub) C++17
100 / 100
12 ms 2492 KB
#include "ricehub.h"

#include <bits/stdc++.h>
using namespace std;

int64_t P[100101];

int besthub(int R, int L, int X[], long long B) {
        int l = 1, r = R, res = -1;
        for (int i = 0; i < R; i++) P[i + 1] = P[i] + X[i];
        while (l <= r) {
                int mid = l + r >> 1;
                bool ok = 0;
                for (int i = mid - 1, j = 0; i < R; i++) {
                        while (j - (i - mid + 1) < i - j) j++;
                        int median = X[j];
                        long long LL = P[j] - P[i - mid + 1];
                        long long RR = P[i + 1] - P[j];
                        LL = 1ll * median * (j - i + mid - 1) - LL;
                        RR = RR - 1ll * median * (i + 1 - j);
                        if (LL + RR <= B) ok = 1;
                }
                if (ok) {
                        res = mid;
                        l = mid + 1;
                } else {
                        r = mid - 1;
                }
        }
        return res;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:12:29: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   12 |                 int mid = l + r >> 1;
      |                           ~~^~~
# 결과 실행 시간 메모리 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 0 ms 212 KB Output is correct
5 Correct 1 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 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 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 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 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 1 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 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 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 0 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 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 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 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 2 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 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 468 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 9 ms 1364 KB Output is correct
4 Correct 10 ms 1364 KB Output is correct
5 Correct 6 ms 1212 KB Output is correct
6 Correct 6 ms 1196 KB Output is correct
7 Correct 12 ms 2280 KB Output is correct
8 Correct 10 ms 2132 KB Output is correct
9 Correct 6 ms 1108 KB Output is correct
10 Correct 6 ms 1108 KB Output is correct
11 Correct 11 ms 2492 KB Output is correct
12 Correct 10 ms 2468 KB Output is correct
13 Correct 7 ms 1236 KB Output is correct
14 Correct 7 ms 1236 KB Output is correct
15 Correct 8 ms 1976 KB Output is correct
16 Correct 8 ms 1876 KB Output is correct
17 Correct 9 ms 2260 KB Output is correct
18 Correct 9 ms 2260 KB Output is correct
19 Correct 9 ms 2320 KB Output is correct
20 Correct 10 ms 2428 KB Output is correct