답안 #125576

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
125576 2019-07-06T02:02:04 Z ksmzzang2003 쌀 창고 (IOI11_ricehub) C++14
컴파일 오류
0 ms 0 KB
#include "ricehub.h"
#include <bits/stdc++.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=1, e = 1,ans = -1987654321;
   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:23:14: error: 'max' was not declared in this scope
        ans = max(ans,e-s+1);
              ^~~
ricehub.cpp:23:14: note: suggested alternative:
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from ricehub.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   'std::max'
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~