답안 #284522

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
284522 2020-08-27T14:36:39 Z Basilhijaz 쌀 창고 (IOI11_ricehub) C++17
100 / 100
29 ms 2944 KB
#include "ricehub.h"

using namespace std;
typedef long long ll;


int besthub(int R, int L, int X[], long long B)
{
    ll pre[R + 1];
    int X2[R + 1];
    X2[0] = 0;
    pre[0] = 0;
    for(int i = 1; i <= R; i++){
        X2[i] = X[i - 1];
        pre[i] = X2[i] + pre[i - 1];
    }
    int lo = 0; int hi = R;
    while(lo < hi){
        ll mid = (lo + hi + 1)/2;
        bool can = 0;
        for(int i = 1; i + mid - 1 <= R; i++){
            ll sum = 0;
            ll nos = (i + i + mid - 1)/2;
            ll k1 = nos - i;
            sum += X2[nos]*k1 - (pre[nos - 1] - pre[i - 1]);
            ll k2 = (i + mid - 1) - nos;
            sum += (pre[i + mid - 1] - pre[nos]) - X2[nos]*k2;
            if(sum <= B){
                can = 1;
                break;
            }
        }
        if(can){
            lo = mid;
        }
        else{
            hi = mid - 1;
        }
    }
    return lo;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 0 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 0 ms 256 KB Output is correct
24 Correct 0 ms 256 KB Output is correct
25 Correct 1 ms 256 KB Output is correct
26 Correct 0 ms 256 KB Output is correct
27 Correct 1 ms 256 KB Output is correct
28 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 640 KB Output is correct
2 Correct 4 ms 768 KB Output is correct
3 Correct 29 ms 2944 KB Output is correct
4 Correct 21 ms 2944 KB Output is correct
5 Correct 9 ms 1408 KB Output is correct
6 Correct 8 ms 1408 KB Output is correct
7 Correct 20 ms 2680 KB Output is correct
8 Correct 15 ms 2616 KB Output is correct
9 Correct 11 ms 1408 KB Output is correct
10 Correct 8 ms 1408 KB Output is correct
11 Correct 22 ms 2944 KB Output is correct
12 Correct 19 ms 2944 KB Output is correct
13 Correct 9 ms 1408 KB Output is correct
14 Correct 12 ms 1408 KB Output is correct
15 Correct 17 ms 2304 KB Output is correct
16 Correct 19 ms 2288 KB Output is correct
17 Correct 21 ms 2688 KB Output is correct
18 Correct 17 ms 2688 KB Output is correct
19 Correct 20 ms 2808 KB Output is correct
20 Correct 23 ms 2816 KB Output is correct