답안 #101108

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
101108 2019-03-16T16:32:00 Z ansol4328 쌀 창고 (IOI11_ricehub) C++11
100 / 100
24 ms 2560 KB
#include<stdio.h>
 
typedef long long ll;
 
int n;
ll b;
ll m[100005];
 
bool pos(int del)
{
    int cnt=n-del;
    int hcnt=cnt/2;
    ll d=0;
    for(int i=1 ; i<=cnt/2 ; i++) d+=m[cnt-i+1]-m[i];
    if(d<=b) return true;
    for(int i=1 ; i<=n-cnt ; i++)
    {
        int didx=i, aidx=i+cnt;
        d-=m[didx+hcnt]-m[didx];
        d+=m[aidx]-m[aidx-hcnt];
        if(d<=b) return true;
    }
    return false;
}
 
int besthub(int R, int L, int *X, long long B)
{
    for(int i=1 ; i<=R ; i++) m[i]=(ll)X[i-1];
    n=R, b=B;
    int st=0, fn=R, mid, res;
    while(st<=fn)
    {
        mid=(st+fn)>>1;
        if(pos(mid)) fn=mid-1, res=mid;
        else st=mid+1;
    }
    return R-res;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:37:14: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
     return R-res;
              ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 3 ms 428 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 3 ms 256 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 3 ms 256 KB Output is correct
27 Correct 2 ms 356 KB Output is correct
28 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 ms 256 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 2 ms 512 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 4 ms 384 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 540 KB Output is correct
2 Correct 9 ms 640 KB Output is correct
3 Correct 20 ms 2532 KB Output is correct
4 Correct 24 ms 2464 KB Output is correct
5 Correct 8 ms 1308 KB Output is correct
6 Correct 9 ms 1152 KB Output is correct
7 Correct 18 ms 2304 KB Output is correct
8 Correct 16 ms 2276 KB Output is correct
9 Correct 10 ms 1152 KB Output is correct
10 Correct 13 ms 1280 KB Output is correct
11 Correct 19 ms 2552 KB Output is correct
12 Correct 21 ms 2560 KB Output is correct
13 Correct 9 ms 1308 KB Output is correct
14 Correct 9 ms 1280 KB Output is correct
15 Correct 16 ms 1920 KB Output is correct
16 Correct 18 ms 1920 KB Output is correct
17 Correct 20 ms 2336 KB Output is correct
18 Correct 19 ms 2296 KB Output is correct
19 Correct 21 ms 2432 KB Output is correct
20 Correct 19 ms 2424 KB Output is correct