답안 #310367

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
310367 2020-10-06T18:05:16 Z JovanK26 쌀 창고 (IOI11_ricehub) C++14
100 / 100
23 ms 2576 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
long long r,l;
long long b;
long long x[100001];
bool check(long long k)
{
    long long rez=0;
    long long m=(k+1)/2;
    for(long long i=1;i<=k;i++)
    {
        rez+=abs(x[m]-x[i]);
    }
    if(rez<=b)return 1;
    m++;
    for(long long i=2;i+k-1<=r;i++,m++)
    {
        if(k&1)rez+=(x[m]-x[m-1]);
        rez-=(x[m]-x[i-1]);
        rez+=(x[i+k-1]-x[m]);
        if(rez<=b)return 1;
    }
    return 0;
}
int besthub(int R, int L, int* X, long long B){

    r=R;
    l=L;
    for(long long i=0;i<r;i++)
    {
        x[i+1]=X[i];
    }
    b=B;
    long long i=0;
    long long j=r;
    while(i<=j)
    {
        long long m=(i+j)/2;
        if(check(m))
        {
            i=m+1;
        }
        else
        {
            j=m-1;
        }
    }
    return i-1;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 488 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 768 KB Output is correct
2 Correct 4 ms 768 KB Output is correct
3 Correct 19 ms 2560 KB Output is correct
4 Correct 19 ms 2556 KB Output is correct
5 Correct 8 ms 1280 KB Output is correct
6 Correct 8 ms 1280 KB Output is correct
7 Correct 17 ms 2304 KB Output is correct
8 Correct 17 ms 2304 KB Output is correct
9 Correct 8 ms 1152 KB Output is correct
10 Correct 8 ms 1172 KB Output is correct
11 Correct 21 ms 2576 KB Output is correct
12 Correct 21 ms 2552 KB Output is correct
13 Correct 9 ms 1280 KB Output is correct
14 Correct 10 ms 1272 KB Output is correct
15 Correct 15 ms 1920 KB Output is correct
16 Correct 16 ms 1920 KB Output is correct
17 Correct 19 ms 2304 KB Output is correct
18 Correct 19 ms 2304 KB Output is correct
19 Correct 21 ms 2432 KB Output is correct
20 Correct 23 ms 2432 KB Output is correct