Submission #125574

# Submission time Handle Problem Language Result Execution time Memory
125574 2019-07-06T02:01:12 Z ksmzzang2003 Rice Hub (IOI11_ricehub) C++14
Compilation error
0 ms 0 KB
#include "ricehub.h"
 
#define MAXN 100005
typedef long long ll;
 
static int N; ll X[MAXN],S[MAXN];
 
ll f(int s,int e)
{
    int t = (s+e)/2;
    return S[e] - S[t] - X[t]*(e-t) +(t-s) *X[t] - (S[t-1]-S[s-1]); 
}
 
int besthub(int n, int L, int x[], ll B)
{
   N = n ;
   for(int i=0;i<N;i++) X[i+1] = x[i];
   for(int i=1;i<=N;i++) S[i] = S[i-1] + X[i];
   int s= e = 1;
   while(1)
   {
       if(s+1<=e && f(s,e)>B) s++;
       ans = max(ans,e-s+1);
       e++;
       if(e>N) break;
   }
   return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, ll)':
ricehub.cpp:19:11: error: 'e' was not declared in this scope
    int s= e = 1;
           ^
ricehub.cpp:23:8: error: 'ans' was not declared in this scope
        ans = max(ans,e-s+1);
        ^~~
ricehub.cpp:23:14: error: 'max' was not declared in this scope
        ans = max(ans,e-s+1);
              ^~~
ricehub.cpp:27:11: error: 'ans' was not declared in this scope
    return ans;
           ^~~