답안 #786002

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
786002 2023-07-17T21:48:59 Z Sputnik1234 쌀 창고 (IOI11_ricehub) C++14
100 / 100
16 ms 3288 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 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 304 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 304 KB Output is correct
28 Correct 1 ms 304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 308 KB Output is correct
19 Correct 1 ms 308 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 468 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 452 KB Output is correct
26 Correct 1 ms 356 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 3 ms 844 KB Output is correct
2 Correct 2 ms 724 KB Output is correct
3 Correct 16 ms 3276 KB Output is correct
4 Correct 10 ms 3252 KB Output is correct
5 Correct 5 ms 1620 KB Output is correct
6 Correct 6 ms 1620 KB Output is correct
7 Correct 9 ms 3028 KB Output is correct
8 Correct 9 ms 2916 KB Output is correct
9 Correct 5 ms 1492 KB Output is correct
10 Correct 5 ms 1492 KB Output is correct
11 Correct 10 ms 3288 KB Output is correct
12 Correct 10 ms 3260 KB Output is correct
13 Correct 5 ms 1596 KB Output is correct
14 Correct 6 ms 1588 KB Output is correct
15 Correct 8 ms 2440 KB Output is correct
16 Correct 7 ms 2516 KB Output is correct
17 Correct 9 ms 2900 KB Output is correct
18 Correct 9 ms 2900 KB Output is correct
19 Correct 9 ms 3084 KB Output is correct
20 Correct 9 ms 3156 KB Output is correct