Submission #28917

# Submission time Handle Problem Language Result Execution time Memory
28917 2017-07-17T19:06:32 Z Nikefor Rice Hub (IOI11_ricehub) C++
Compilation error
0 ms 0 KB
#include "ricehub.h"
#include<algorithm>
int field[10001];
int besthub(int R, int L, int X[], long long B)
{
    int optimalGain=0;
    int m, l, r;
    l = r = m = 0;
    long long spent = 0;
    int localGain = 0;


        while(r<R) {
            if(r!=(R-1))r++;
            m = ((r-l)%2)?(r+l+1)/2:(r+l)/2;
            spent+= X[r]-X[m];
            if(spent>B) {
                optimalGain = max(optimalGain, localGain);
                while(spent>B) {
                    l++;
                    spent-= X[l]-X[m];
                    m = ((r-l)%2)?(r+l+1)/2:(r+l)/2;
                    localGain--;
                }

                continue;
            }
            localGain++;
        }


  return optimalGain ;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:18:57: error: 'max' was not declared in this scope
                 optimalGain = max(optimalGain, localGain);
                                                         ^
ricehub.cpp:18:57: note: suggested alternative:
In file included from /usr/include/c++/5/algorithm:61:0,
                 from ricehub.cpp:2:
/usr/include/c++/5/bits/stl_algobase.h:265:5: note:   'std::max'
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^