Submission #101106

# Submission time Handle Problem Language Result Execution time Memory
101106 2019-03-16T16:23:00 Z ansol4328 Rice Hub (IOI11_ricehub) C++11
0 / 100
5 ms 384 KB
#include<stdio.h>

bool pos(int del, int *m, long long B, int n)
{
    int cnt=n-del;
    int hcnt=cnt/2;
    long long d=0;
    for(int i=0 ; i<cnt/2 ; i++) d+=(long long)m[cnt-i+1]-m[i];
    if(d<=B) return true;
    for(int i=0 ; i<n-cnt ; i++)
    {
        int didx=i, aidx=i+cnt;
        d-=(long long)m[didx+hcnt]-m[didx];
        d+=(long long)m[aidx]-m[aidx-hcnt];
        if(d<=B) return true;
    }
    return false;
}

int besthub(int R, int L, int *X, long long B)
{
    int st=0, fn=R, mid, res;
    while(st<=fn)
    {
        mid=(st+fn)>>1;
        if(pos(mid,X,B,R)) 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:29:14: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
     return R-res;
              ^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 252 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Incorrect 3 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -