답안 #598957

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
598957 2022-07-19T08:22:22 Z Summers 쌀 창고 (IOI11_ricehub) C++14
100 / 100
13 ms 1500 KB
#include "ricehub.h"
#include<iostream>
using namespace std;
long long pref[1000000];
int besthub(int R, int L, int X[], long long B)
{
    long long i, ans=0, le, ri, mid;

    for(i=0;i<R;i++)
    {
       if(i!=0) pref[i]=pref[i-1]+X[i];
       else pref[i]=X[i];
    }

    le=0; ri=0;

    while(ri<R)
    {
        mid=(le+ri)/2;

        long long ledist= 0, ridist = pref[ri]-pref[mid];

        if(le>=1 && mid>=1)ledist = pref[mid-1]-pref[le-1];
        else if(mid>=1)ledist=pref[mid-1];

        long long sum=((mid-le)*X[mid]-ledist)+(ridist-(ri-mid)*(X[mid]));

        if(sum<=B)
        {
            ans=max(ans, ri-le+1);
            ri++;
        }
        else
        {
            le++;
            ri++;
        }

    }

    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 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 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 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 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 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 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 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 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 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 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 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 2 ms 468 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 11 ms 1448 KB Output is correct
4 Correct 12 ms 1428 KB Output is correct
5 Correct 5 ms 904 KB Output is correct
6 Correct 5 ms 852 KB Output is correct
7 Correct 10 ms 1436 KB Output is correct
8 Correct 9 ms 1476 KB Output is correct
9 Correct 5 ms 852 KB Output is correct
10 Correct 4 ms 852 KB Output is correct
11 Correct 10 ms 1364 KB Output is correct
12 Correct 11 ms 1500 KB Output is correct
13 Correct 5 ms 852 KB Output is correct
14 Correct 5 ms 852 KB Output is correct
15 Correct 8 ms 1108 KB Output is correct
16 Correct 8 ms 1108 KB Output is correct
17 Correct 13 ms 1252 KB Output is correct
18 Correct 10 ms 1240 KB Output is correct
19 Correct 12 ms 1364 KB Output is correct
20 Correct 11 ms 1364 KB Output is correct