Submission #1216674

#TimeUsernameProblemLanguageResultExecution timeMemory
1216674semiautoRice Hub (IOI11_ricehub)C++20
Compilation error
0 ms0 KiB
#include "ricehub.h"
using namespace std;
int besthub(int R, int L, int x[], long long B)
{
  int ans = 0;
  for (int i = 0; i < R; i++) {
    int a[R];
    for (int j = 0; j < R; j++) {
      a[j] = abs(x[i] - x[j]);
    }
    sort(a, a + R);
    long long sum = B;
    int cur = 0;
    for (int j = 0; j < R; j++) {
      if (a[j] > sum) {
        break;
      }
      sum -= a[j];
      cur++;
    }
    ans = max(ans, cur);
  }
  return ans;
}

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:9:14: error: 'abs' was not declared in this scope; did you mean 'ans'?
    9 |       a[j] = abs(x[i] - x[j]);
      |              ^~~
      |              ans
ricehub.cpp:11:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   11 |     sort(a, a + R);
      |     ^~~~
      |     short
ricehub.cpp:21:11: error: 'max' was not declared in this scope
   21 |     ans = max(ans, cur);
      |           ^~~