답안 #388077

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
388077 2021-04-09T22:00:24 Z Pichon5 쌀 창고 (IOI11_ricehub) C++17
100 / 100
22 ms 2524 KB
#include "ricehub.h"
#include <bits/stdc++.h>
#define vi vector<int>
#define pb push_back
#define ll long long int
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
    int res=0;
    ll pref[R];
    pref[0]=X[0];
    for(int i=1;i<R;i++){
        pref[i]=pref[i-1]+X[i];
    }
    for(ll i=0;i<R;i++){
        ll b=i,e=R-1;
        while(b<=e){
            ll mid=(b+e)/2;
            ll MID=(i+mid)/2;
            ll aux=pref[mid];
            aux-=pref[MID];
            aux-=(mid-MID)*X[MID];
            if(MID!=i){
                aux+=(MID-i)*X[MID];
                aux-=pref[MID-1];
                if(i)aux+=pref[i-1];
            }
            if(aux<=B){
                res=max(res,int(mid-i+1));
                b=mid+1;
            }else{
                e=mid-1;
            }
        }
    }
    return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 460 KB Output is correct
2 Correct 4 ms 460 KB Output is correct
3 Correct 21 ms 1380 KB Output is correct
4 Correct 22 ms 2448 KB Output is correct
5 Correct 9 ms 1156 KB Output is correct
6 Correct 10 ms 1280 KB Output is correct
7 Correct 19 ms 2220 KB Output is correct
8 Correct 20 ms 2224 KB Output is correct
9 Correct 10 ms 1116 KB Output is correct
10 Correct 10 ms 1192 KB Output is correct
11 Correct 21 ms 2516 KB Output is correct
12 Correct 22 ms 2524 KB Output is correct
13 Correct 10 ms 1228 KB Output is correct
14 Correct 12 ms 1244 KB Output is correct
15 Correct 16 ms 1884 KB Output is correct
16 Correct 16 ms 1860 KB Output is correct
17 Correct 19 ms 2260 KB Output is correct
18 Correct 19 ms 2268 KB Output is correct
19 Correct 20 ms 2372 KB Output is correct
20 Correct 20 ms 2368 KB Output is correct