답안 #996405

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
996405 2024-06-10T14:44:53 Z phoenix 쌀 창고 (IOI11_ricehub) C++17
100 / 100
19 ms 4220 KB
#include<bits/stdc++.h>

using namespace std;


int besthub(int R, int L, int X[], long long B) {
    long long pref[ R ];
    for(int i = 0;i < R;i++) {
        pref[ i ] = X[ i ];
        if(i) pref[ i ] += pref[i - 1];
    }
    auto sum = [&](int l, int r) {
        if(l > r) return 0ll;
        return pref[r] - (l ? pref[l-1] : 0);
    };
    auto func = [&](int l, int r) {
        int m = (l + r) / 2;
        return sum(m + 1, r) - sum(l, m - 1) - X[m] * ((r - l) % 2);
    };
    int res = 0;
    for(int i = 0;i < R;i++) {
        int l = -1, r = i;
        while(r - l > 1) {
            int m = (l + r) / 2;
            if(func(m, i) <= B) r = m;
            else l = m;
        }
        res = max(res, i - l);
    }
    return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 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 348 KB Output is correct
7 Correct 1 ms 344 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 344 KB Output is correct
15 Correct 1 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 604 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 444 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 448 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 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 448 KB Output is correct
11 Correct 0 ms 344 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 452 KB Output is correct
15 Correct 1 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 484 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 456 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 604 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 19 ms 4040 KB Output is correct
4 Correct 19 ms 4188 KB Output is correct
5 Correct 8 ms 3276 KB Output is correct
6 Correct 8 ms 3160 KB Output is correct
7 Correct 16 ms 4220 KB Output is correct
8 Correct 17 ms 4188 KB Output is correct
9 Correct 8 ms 3164 KB Output is correct
10 Correct 8 ms 3284 KB Output is correct
11 Correct 19 ms 4188 KB Output is correct
12 Correct 18 ms 4208 KB Output is correct
13 Correct 9 ms 3416 KB Output is correct
14 Correct 9 ms 3420 KB Output is correct
15 Correct 14 ms 3784 KB Output is correct
16 Correct 14 ms 4016 KB Output is correct
17 Correct 17 ms 3928 KB Output is correct
18 Correct 16 ms 3932 KB Output is correct
19 Correct 17 ms 3932 KB Output is correct
20 Correct 18 ms 4184 KB Output is correct