Submission #1354859

#TimeUsernameProblemLanguageResultExecution timeMemory
1354859Charizard2021쌀 창고 (IOI11_ricehub)C++20
Compilation error
0 ms0 KiB
#include "ricehub.h"
int besthub(int R, int L, int X[], long long B){
    int res = 0;
    for(int i = 1; i <= L; i++){
        vector<long long> dist;
        for(int j = 0; j < R; j++){
            dist.push_back(abs(i - X[j]));
        }
        sort(dist.begin(), dist.end());
        long long cur = 0;
        int cnt = 0;
        for(int j = 0; j < R; j++){
            if(cur + dist[j] <= B){
                cur += dist[j];
                cnt++;
            }
        }
        res = max(res, cnt);
    }
    return res;
}

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:5:9: error: 'vector' was not declared in this scope
    5 |         vector<long long> dist;
      |         ^~~~~~
ricehub.cpp:5:16: error: expected primary-expression before 'long'
    5 |         vector<long long> dist;
      |                ^~~~
ricehub.cpp:7:13: error: 'dist' was not declared in this scope
    7 |             dist.push_back(abs(i - X[j]));
      |             ^~~~
ricehub.cpp:7:28: error: 'abs' was not declared in this scope
    7 |             dist.push_back(abs(i - X[j]));
      |                            ^~~
ricehub.cpp:9:14: error: 'dist' was not declared in this scope
    9 |         sort(dist.begin(), dist.end());
      |              ^~~~
ricehub.cpp:9:9: error: 'sort' was not declared in this scope; did you mean 'short'?
    9 |         sort(dist.begin(), dist.end());
      |         ^~~~
      |         short
ricehub.cpp:18:15: error: 'max' was not declared in this scope
   18 |         res = max(res, cnt);
      |               ^~~