Submission #1015119

# Submission time Handle Problem Language Result Execution time Memory
1015119 2024-07-06T06:20:26 Z KasymK Rice Hub (IOI11_ricehub) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "ricehub.h"
#define ll long long
#define ff first
#define ss second
#define all(v) v.begin(), v.end()

int best_hub(int r, int l, int x[], ll b){
    int answer = 0;
    deque<int> diff;
    for(int cor = 1; cor <= l; ++cor){
        diff.clear();
        int sm = 0;
        for(int i = 0; i < r; ++i)
            diff.push_back(abs(cor-x[i]));
        sort(all(diff));
        while(1){
            if(b-diff[0] >= 0)
                b -= diff[0], diff.pop_front(), sm++;
            else
                break;
        }
        answer = max(answer, sm);
    }
    return answer;
}

Compilation message

ricehub.cpp: In function 'int best_hub(int, int, int*, long long int)':
ricehub.cpp:10:5: error: 'deque' was not declared in this scope
   10 |     deque<int> diff;
      |     ^~~~~
ricehub.cpp:10:5: note: suggested alternatives:
In file included from /usr/include/c++/10/deque:67,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:68,
                 from ricehub.cpp:1:
/usr/include/c++/10/bits/stl_deque.h:764:11: note:   'std::deque'
  764 |     class deque : protected _Deque_base<_Tp, _Alloc>
      |           ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:68,
                 from ricehub.cpp:1:
/usr/include/c++/10/deque:83:13: note:   'std::pmr::deque'
   83 |       using deque = std::deque<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~
ricehub.cpp:10:11: error: expected primary-expression before 'int'
   10 |     deque<int> diff;
      |           ^~~
ricehub.cpp:12:9: error: 'diff' was not declared in this scope
   12 |         diff.clear();
      |         ^~~~
ricehub.cpp:16:9: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   16 |         sort(all(diff));
      |         ^~~~
      |         std::sort
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from ricehub.cpp:1:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
ricehub.cpp:23:18: error: 'max' was not declared in this scope; did you mean 'std::max'?
   23 |         answer = max(answer, sm);
      |                  ^~~
      |                  std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from ricehub.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~