답안 #422234

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
422234 2021-06-09T22:40:43 Z ScarletS 쌀 창고 (IOI11_ricehub) C++17
0 / 100
19 ms 1756 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;
    //cout<<L<<"!!\n";
    long long cur;
    while (l<r)
    {
        ok=0;
        m=l+(r-l)/2+1;
        //cout<<m<<"!\n";
        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];
        // cout<<cur<<"\n";
        // cout<<1LL*a[(x+y)/2]*((m-1)/2+1)<<" "<<-1LL*a[(x+y)/2]*(m-(m-1)/2-1)<<"\n";
        //cout<<cur+1LL*a[(x+y)/2]*((m-1)/2+1)-1LL*a[(x+y)/2]*(m-(m-1)/2-1)<<" ";
        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 (;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;
            //cout<<cur+1LL*a[(x+y)/2]*((m-1)/2+1)-1LL*a[(x+y)/2]*(m-(m-1)/2-1)<<" ";
        }
        //cout<<"\n";
        if (ok)
            l=m;
        else
            r=m-1;
    }
    return l;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 296 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Incorrect 1 ms 204 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 4 ms 460 KB Output is correct
3 Correct 17 ms 1732 KB Output is correct
4 Correct 17 ms 1756 KB Output is correct
5 Correct 9 ms 708 KB Output is correct
6 Correct 9 ms 844 KB Output is correct
7 Correct 15 ms 1356 KB Output is correct
8 Correct 15 ms 1464 KB Output is correct
9 Correct 8 ms 716 KB Output is correct
10 Correct 9 ms 716 KB Output is correct
11 Correct 17 ms 1736 KB Output is correct
12 Correct 19 ms 1756 KB Output is correct
13 Correct 9 ms 844 KB Output is correct
14 Incorrect 9 ms 832 KB Output isn't correct
15 Halted 0 ms 0 KB -