답안 #28915

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
28915 2017-07-17T19:04:30 Z Nikefor 쌀 창고 (IOI11_ricehub) C++
컴파일 오류
0 ms 0 KB
#include "ricehub.h"
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]-[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 lambda function:
ricehub.cpp:15:29: error: expected '{' before ';' token
             spent+= X[r]-[m];
                             ^
ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:15:29: warning: lambda expressions only available with -std=c++11 or -std=gnu++11
ricehub.cpp:15:25: error: no match for 'operator-' (operand types are 'int' and 'besthub(int, int, int*, long long int)::<lambda()>')
             spent+= X[r]-[m];
                         ^
ricehub.cpp:17:57: error: 'max' was not declared in this scope
                 optimalGain = max(optimalGain, localGain);
                                                         ^