제출 #1216674

#제출 시각아이디문제언어결과실행 시간메모리
1216674semiauto쌀 창고 (IOI11_ricehub)C++20
컴파일 에러
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; }

컴파일 시 표준 에러 (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);
      |           ^~~