Submission #655195

# Submission time Handle Problem Language Result Execution time Memory
655195 2022-11-03T14:18:35 Z PanTkd Rice Hub (IOI11_ricehub) C++14
Compilation error
0 ms 0 KB
#include "ricehub.h"
typedef long long ll;
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
  for(ll i = R;i>=1;i--){
    for(ll j = 0;j<R-i;j++){
      ll cost = 0;
      ll med = i/2+j;
      for(ll k = j ;k<=j+i-1 && k<=R;k++){
        cost+= abs(X[med]-X[k]);
      }
      if(cost<=B)
        return i;
    }
  }
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:11:16: error: 'abs' was not declared in this scope
   11 |         cost+= abs(X[med]-X[k]);
      |                ^~~
ricehub.cpp:17:1: warning: control reaches end of non-void function [-Wreturn-type]
   17 | }
      | ^