답안 #422242

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
422242 2021-06-09T22:49:06 Z ScarletS 쌀 창고 (IOI11_ricehub) C++17
100 / 100
19 ms 668 KB
#include <bits/stdc++.h>
using namespace std;

int besthub(int R, int L, int a[], long long B)
{
    int l=0,r=R,m,x,y;
    bool ok;
    long long cur;
    while (l<r)
    {
        ok=0;
        m=l+(r-l)/2+1;
        cur=0;
        x=0;y=m-1;
        for (int i=0;i<=y/2;++i)
            cur-=a[i];
        for (int i=y/2+1;i<m;++i)
            cur+=a[i];
        if (cur+1LL*a[(x+y)/2]*((m-1)/2+1)-1LL*a[(x+y)/2]*(m-(m-1)/2-1)<=B)
            ok=1;
        for (++x,++y;y<R;++x,++y)
        {
            cur+=a[x-1];
            cur+=a[y];
            cur-=a[(x+y)/2]*2;
            if (cur+1LL*a[(x+y)/2]*((m-1)/2+1)-1LL*a[(x+y)/2]*(m-(m-1)/2-1)<=B)
                ok=1;
        }
        if (ok)
            l=m;
        else
            r=m-1;
    }
    return l;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 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 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 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 1 ms 204 KB Output is correct
13 Correct 1 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 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 1 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 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 1 ms 204 KB Output is correct
10 Correct 0 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 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 332 KB Output is correct
2 Correct 4 ms 332 KB Output is correct
3 Correct 16 ms 588 KB Output is correct
4 Correct 15 ms 668 KB Output is correct
5 Correct 8 ms 460 KB Output is correct
6 Correct 8 ms 460 KB Output is correct
7 Correct 13 ms 628 KB Output is correct
8 Correct 13 ms 588 KB Output is correct
9 Correct 11 ms 460 KB Output is correct
10 Correct 8 ms 460 KB Output is correct
11 Correct 16 ms 588 KB Output is correct
12 Correct 19 ms 588 KB Output is correct
13 Correct 9 ms 460 KB Output is correct
14 Correct 9 ms 496 KB Output is correct
15 Correct 11 ms 472 KB Output is correct
16 Correct 12 ms 524 KB Output is correct
17 Correct 14 ms 616 KB Output is correct
18 Correct 14 ms 652 KB Output is correct
19 Correct 16 ms 556 KB Output is correct
20 Correct 15 ms 588 KB Output is correct