Submission #16221

# Submission time Handle Problem Language Result Execution time Memory
16221 2015-08-18T10:04:37 Z ggoh Rice Hub (IOI11_ricehub) C++
Compilation error
0 ms 0 KB
#include "ricehub.h"
#include<cstdio>
long long besthub(int R,int L,int *X,long long B)
{
    long long ch,s,p,q,h,i;
    p=0;q=R+1;
    while(p!=q-1)
    {
        h=(p+q)/2;
        s=0;
        ch=0;
        for(i=h/2;i<h;i++)
        {
            s+=(X[i]-X[h-1-i]);
        }
        if(s<=B)ch=1;
        for(i=h;i<R&&ch==0;i++)
        {
            s+=(X[i]-X[i-h/2]);
            s-=(X[i-h/2]-X[i-h]);
            if(s<=B)ch=1;
        }
        if(ch)p=h;
        else q=h;
    }
    return p;
}

Compilation message

ricehub.cpp: In function ‘long long int besthub(int, int, int*, long long int)’:
ricehub.cpp:3:49: error: ambiguating new declaration of ‘long long int besthub(int, int, int*, long long int)’
 long long besthub(int R,int L,int *X,long long B)
                                                 ^
In file included from ricehub.cpp:1:0:
ricehub.h:1:5: note: old declaration ‘int besthub(int, int, int*, long long int)’
 int besthub(int R, int L, int X[], long long B);
     ^