답안 #598939

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
598939 2022-07-19T08:11:00 Z daisy2 쌀 창고 (IOI11_ricehub) C++14
100 / 100
16 ms 2516 KB
#include<iostream>
#include "ricehub.h"
using namespace std;
long long pr[100005];
int besthub(int R, int L, int X[], long long B)
{
    pr[0]=X[0];
    for(int i=1;i<R;i++)
      pr[i]=pr[i-1]+X[i];

    long long le,l,r,bud,bx,prl,prr,md=0;
    for(int ri=0;ri<R;ri++)
    {
        l=0;r=ri;
        while(l<=r)
        {
            le=(l+r)/2;

            bx=(ri+le)/2;

            prl=0;
            if(le>0 && bx>0)
               prl=(pr[bx-1]-pr[le-1]);
            else if(bx>0)
                prl=pr[bx-1];

            prr=pr[ri]-pr[bx];

            bud=X[bx]*(bx-le)-prl+prr-X[bx]*(ri-bx);

            if(bud>B)
              l=le+1;
            else r=le-1;
        }
        md=max(md,(ri-l+1));
    }

    return md;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 220 KB Output is correct
15 Correct 0 ms 216 KB Output is correct
16 Correct 1 ms 220 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 304 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 308 KB Output is correct
22 Correct 1 ms 308 KB Output is correct
23 Correct 1 ms 312 KB Output is correct
24 Correct 0 ms 308 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 304 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 468 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 15 ms 2484 KB Output is correct
4 Correct 15 ms 2516 KB Output is correct
5 Correct 7 ms 1240 KB Output is correct
6 Correct 6 ms 1236 KB Output is correct
7 Correct 16 ms 2220 KB Output is correct
8 Correct 13 ms 2216 KB Output is correct
9 Correct 7 ms 1108 KB Output is correct
10 Correct 8 ms 1188 KB Output is correct
11 Correct 15 ms 2508 KB Output is correct
12 Correct 15 ms 2464 KB Output is correct
13 Correct 8 ms 1236 KB Output is correct
14 Correct 12 ms 1276 KB Output is correct
15 Correct 12 ms 1976 KB Output is correct
16 Correct 11 ms 1876 KB Output is correct
17 Correct 14 ms 2364 KB Output is correct
18 Correct 13 ms 2260 KB Output is correct
19 Correct 14 ms 2388 KB Output is correct
20 Correct 15 ms 2360 KB Output is correct