답안 #146599

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
146599 2019-08-24T16:30:56 Z MathStudent2002 쌀 창고 (IOI11_ricehub) C++14
100 / 100
20 ms 3452 KB
#include "ricehub.h"
//#include "grader.cpp"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MAXR = 100005;
const ll INFTY = 1000000000000000007;

ll Rval;
ll loc[MAXR];
ll psum[MAXR];

void init() {
    psum[0] = 0;
    for(int i = 1; i <= Rval; i++) {psum[i] = psum[i-1] + loc[i];}
}

ll quer(int l, int r) {
    return psum[r] - psum[l-1];
}

ll mincost(int P) { // minimum cost of P paddies
    ll ans = INFTY;
    for(int i = 0; i+P <= Rval; i++) {//checking i+1...i+P
        ans = min(ans, quer(i+1+P-P/2, i+P) - quer(i+1, i+P/2));
    }
    return ans;
}

int besthub(int R, int L, int X[], long long B) {
    Rval = R;
    for(int i = 0; i < R; i++) {loc[i+1] = X[i];}
    init();
    int lo = 1, hi = R;
    int mi;
    while(lo != hi) {
        mi = (lo+hi+1)/2;
        if(mincost(mi) <= B) {lo = mi;}
        else {hi = mi-1;}
    }

    return lo;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 404 KB Output is correct
23 Correct 2 ms 380 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 2 ms 404 KB Output is correct
9 Correct 2 ms 400 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 404 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 3 ms 476 KB Output is correct
22 Correct 3 ms 380 KB Output is correct
23 Correct 3 ms 504 KB Output is correct
24 Correct 3 ms 504 KB Output is correct
25 Correct 3 ms 504 KB Output is correct
26 Correct 3 ms 504 KB Output is correct
27 Correct 3 ms 504 KB Output is correct
28 Correct 3 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 888 KB Output is correct
2 Correct 5 ms 888 KB Output is correct
3 Correct 18 ms 3320 KB Output is correct
4 Correct 18 ms 3452 KB Output is correct
5 Correct 10 ms 1656 KB Output is correct
6 Correct 9 ms 1660 KB Output is correct
7 Correct 16 ms 3036 KB Output is correct
8 Correct 16 ms 3064 KB Output is correct
9 Correct 9 ms 1656 KB Output is correct
10 Correct 9 ms 1544 KB Output is correct
11 Correct 20 ms 3320 KB Output is correct
12 Correct 20 ms 3320 KB Output is correct
13 Correct 10 ms 1656 KB Output is correct
14 Correct 10 ms 1660 KB Output is correct
15 Correct 15 ms 2552 KB Output is correct
16 Correct 15 ms 2552 KB Output is correct
17 Correct 18 ms 3064 KB Output is correct
18 Correct 18 ms 3068 KB Output is correct
19 Correct 19 ms 3192 KB Output is correct
20 Correct 19 ms 3192 KB Output is correct