Submission #503106

#TimeUsernameProblemLanguageResultExecution timeMemory
503106colossal_pepeWatching (JOI13_watching)C++17
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; int n, p, q; vector<int> v; int brutus(int w, int i, int p_left, vector<vector<int>> &dp) { if (i >= n) return 0; if (dp[i][p_left] != -1) return dp[i][p_left]; int useq = lower_bound(v.begin(), v.end(), v[i] + (2 * w)) - v.begin(); dp[i][p_left] = brutus(w, useq, p_left, dp) + 1; if (p_left) { int usep = lower_bound(v.begin(), v.end(), v[i] + w) - v.begin(); dp[i][p_left] = min(dp[i][p_left], brutus(w, usep, p_left - 1, dp)); } return dp[i][p_left]; } int solve() { vector<vector<int>> dp(n, vector<int>(p + 1, -1)); int minw = 1, maxw = 1e9; while (maxw - minw >= 5) { int mid = (maxw + minw) / 2; fill(dp.begin(), dp.end(), -1); if (brutus(mid, 0, p, dp) <= q) maxw = mid; else minw = mid + 1; } for (int i = minw; i <= maxw; i++) { fill(dp.begin(), dp.end(), -1); if (brutus(i, 0, p, dp) <= q) return i; } return 1e9; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> p >> q; v.resize(n); for (int &i : v) { cin >> i; } sort(v.begin(), v.end()); cout << solve() << '\n'; return 0; }

Compilation message (stderr)

In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from watching.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h: In instantiation of 'typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = std::vector<int>*; _Tp = int; typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type = void]':
/usr/include/c++/10/bits/stl_algobase.h:902:21:   required from 'void std::__fill_a1(__gnu_cxx::__normal_iterator<_Iterator, _Container>, __gnu_cxx::__normal_iterator<_Iterator, _Container>, const _Tp&) [with _Ite = std::vector<int>*; _Cont = std::vector<std::vector<int> >; _Tp = int]'
/usr/include/c++/10/bits/stl_algobase.h:914:21:   required from 'void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int> > >; _Tp = int]'
/usr/include/c++/10/bits/stl_algobase.h:944:20:   required from 'void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int> > >; _Tp = int]'
watching.cpp:26:38:   required from here
/usr/include/c++/10/bits/stl_algobase.h:873:11: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'const int')
  873 |  *__first = __tmp;
      |  ~~~~~~~~~^~~~~~~
In file included from /usr/include/c++/10/vector:72,
                 from watching.cpp:2:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'const int' to 'const std::vector<int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from watching.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'const int' to 'std::vector<int>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'const int' to 'std::initializer_list<int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~