답안 #460713

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
460713 2021-08-09T08:29:51 Z BT21tata 쌀 창고 (IOI11_ricehub) C++17
100 / 100
28 ms 3252 KB
#include "ricehub.h"
#include<bits/stdc++.h>

typedef long long ll;

using namespace std;

ll cnt[100005], a[100005];

ll check(int x, int n)
{
    int lnum=x>>1;
    int rnum=x-lnum-1;
    ll ans=0, cur, ret=1e18;
    for(int i=lnum; i<n-rnum; i++)
    {
        cur=cnt[i]-cnt[i-lnum];
        ans=lnum*a[i]-cur;

        cur=cnt[i+rnum+1]-cnt[i+1];
        ans+=(cur-rnum*a[i]);

        ret=min(ans, ret);
    }
    return ret;
}

int besthub(int n, int len, int X[], long long m)
{
    for(int i=0; i<n; i++)
        cnt[i+1]=cnt[i]+X[i], a[i]=X[i];

    int l=0, r=n, mid;
    while(l<=r)
    {
        mid=(l+r)>>1;
    //    cout<<l<<' ' <<r<<' '<<mid<<' '<<check(mid, n)<<endl;
        if(check(mid, n)<=m) l=mid+1;
        else r=mid-1;
    }
    return r;
}

/*


5 20 6
1 2 10 12 14
3

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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
# 결과 실행 시간 메모리 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 0 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 1 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 0 ms 204 KB Output is correct
13 Correct 0 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 1 ms 204 KB Output is correct
20 Correct 0 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 0 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 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 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 1 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 1 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 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 396 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 588 KB Output is correct
2 Correct 4 ms 588 KB Output is correct
3 Correct 18 ms 2252 KB Output is correct
4 Correct 28 ms 2136 KB Output is correct
5 Correct 10 ms 1608 KB Output is correct
6 Correct 8 ms 1588 KB Output is correct
7 Correct 13 ms 3020 KB Output is correct
8 Correct 13 ms 3020 KB Output is correct
9 Correct 11 ms 1484 KB Output is correct
10 Correct 8 ms 1484 KB Output is correct
11 Correct 17 ms 3252 KB Output is correct
12 Correct 18 ms 3248 KB Output is correct
13 Correct 11 ms 1612 KB Output is correct
14 Correct 9 ms 1612 KB Output is correct
15 Correct 11 ms 2508 KB Output is correct
16 Correct 12 ms 2508 KB Output is correct
17 Correct 13 ms 2892 KB Output is correct
18 Correct 14 ms 2988 KB Output is correct
19 Correct 14 ms 3164 KB Output is correct
20 Correct 14 ms 3096 KB Output is correct