답안 #516272

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
516272 2022-01-21T01:28:46 Z Jesus 쌀 창고 (IOI11_ricehub) C++14
컴파일 오류
0 ms 0 KB
#include <iostream>
#include "ricehub.h"

int besthub(int R, int L,int X[], long long int B){
    long long int izq=0, der=0, maxim=0;
    long long int costo=0;
    int i=0,j=0;
    int z=0;
    while(i<R){
        if(j==R-1||costo>B) {
                if(izq<der){
                    z=(i+j)/2;
                    costo-=X[z+1]-X[z-izq];
                    costo+=(X[z+1]-X[z])*(izq);
                    costo-=(X[z+1]-X[z])*(der);
                    izq++;
                    der--;

                }
                i++;
                izq--;
        }
        else{
            z=(i+j)/2;
            if(izq<der){
                costo+=X[z+1+der]-X[z+1];
                costo+=(X[z+1]-X[z])*izq;
                costo-=(X[z+1]-X[z])*(der-1);
                izq++;
                der--;
            }
            else{
                costo+=X[z+der+1]-X[z];
            }
            j++;
            der++;
        }
        if(costo<=B) maxim=max(maxim,der+izq+1);

    }
    return maxim;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:38:28: error: 'max' was not declared in this scope; did you mean 'std::max'?
   38 |         if(costo<=B) maxim=max(maxim,der+izq+1);
      |                            ^~~
      |                            std::max
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from ricehub.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: 'std::max' declared here
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~