답안 #969914

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
969914 2024-04-25T20:01:51 Z urieg 쌀 창고 (IOI11_ricehub) C++17
74 / 100
14 ms 5212 KB

#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
typedef long long ll;
/// for moondance

int besthub(int R, int L, int X[], long long B){

    vector<ll>x(R), p(R);
    for(int i=0;i<R;i++){
        x[i] = X[i];
        p[i] = x[i];
        if(i)p[i] += p[i-1];
    }

    ll sum = 0;
    int l = 1, r = R;
    while(l<r){
        int m = (l+r+1)/2;
        bool ok = 0;
        for(int i = 0;i+m<=R; i++){
            int L = i, R = i+m-1;
            int mid = (R+L)/2;
            sum = p[R] - p[mid] - (x[mid]*(R-mid));
            sum += x[mid]*(mid-L+1) - (!L ? 0 : p[mid]-p[L-1]);
//            cout<<L<<' '<<R<<' '<<mid<<' '<<sum<<endl;
            if(sum <= B){
                ok = 1;
                break;
            }
        }
//        cout<<m<<' '<<ok<<endl;
        if(ok){
            l = m;
        }
        else r = m-1;
    }
    return l;
}




# 결과 실행 시간 메모리 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 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 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 1 ms 348 KB Output is correct
6 Correct 0 ms 448 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 444 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 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 1 ms 344 KB Output is correct
2 Correct 1 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
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 448 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 436 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 448 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 456 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Incorrect 1 ms 348 KB Output isn't correct
26 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 860 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 12 ms 4952 KB Output is correct
4 Correct 10 ms 5212 KB Output is correct
5 Correct 7 ms 3780 KB Output is correct
6 Correct 6 ms 3676 KB Output is correct
7 Correct 9 ms 4960 KB Output is correct
8 Correct 9 ms 4916 KB Output is correct
9 Correct 7 ms 3636 KB Output is correct
10 Correct 5 ms 3676 KB Output is correct
11 Correct 12 ms 5212 KB Output is correct
12 Correct 14 ms 5092 KB Output is correct
13 Correct 7 ms 3676 KB Output is correct
14 Correct 6 ms 3676 KB Output is correct
15 Correct 9 ms 4700 KB Output is correct
16 Correct 7 ms 4448 KB Output is correct
17 Correct 9 ms 4952 KB Output is correct
18 Correct 10 ms 4956 KB Output is correct
19 Correct 9 ms 4956 KB Output is correct
20 Correct 11 ms 5168 KB Output is correct