Submission #567892

#TimeUsernameProblemLanguageResultExecution timeMemory
567892Trisanu_DasBoxes with souvenirs (IOI15_boxes)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int int delivery(int n, int k, int l, int a){ int dp1[n + 1], dp2[n + 1], pos[n + 1]; dp1[0] = 0; dp2[0] = 0; for(int i = 0; i < n; i++) pos[i + 1] = a[i]; sort(a + 1, a + n + 1); for(int i = 1; i <= n ; i++){ dp1[i] = dp1[max(0, i - k)] + 2 * pos[i]; } for(int i = 1; i <= n ; i++){ dp2[i] = 2 * (l - pos[i]) + dp2[min(n + 1, i + k)]; } int ans = 1e18; for (int i = 1;i < n + 1;i++) ans = min(ans, dp1[i - 1] + dp2[i]); for (int i = k;i <= n;i++) ans = min(ans, dp[i - k] + dp2[i + 1] + l); return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(long long int, long long int, long long int, long long int)':
boxes.cpp:7:44: error: invalid types 'long long int[long long int]' for array subscript
    7 |   for(int i = 0; i < n; i++) pos[i + 1] = a[i];
      |                                            ^
boxes.cpp:10:30: error: no matching function for call to 'max(int, long long int)'
   10 |     dp1[i] = dp1[max(0, i - k)] + 2 * pos[i];
      |                              ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from boxes.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
boxes.cpp:10:30: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   10 |     dp1[i] = dp1[max(0, i - k)] + 2 * pos[i];
      |                              ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from boxes.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
boxes.cpp:10:30: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   10 |     dp1[i] = dp1[max(0, i - k)] + 2 * pos[i];
      |                              ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from boxes.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
boxes.cpp:10:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   10 |     dp1[i] = dp1[max(0, i - k)] + 2 * pos[i];
      |                              ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from boxes.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
boxes.cpp:10:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   10 |     dp1[i] = dp1[max(0, i - k)] + 2 * pos[i];
      |                              ^
boxes.cpp:17:45: error: 'dp' was not declared in this scope; did you mean 'dp2'?
   17 |   for (int i = k;i <= n;i++) ans = min(ans, dp[i - k] + dp2[i + 1] + l);
      |                                             ^~
      |                                             dp2
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from boxes.cpp:1:
/usr/include/c++/10/bits/stl_algo.h: In instantiation of 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = long long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]':
/usr/include/c++/10/bits/stl_algo.h:1886:25:   required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = long long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
/usr/include/c++/10/bits/stl_algo.h:1977:31:   required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = long long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
/usr/include/c++/10/bits/stl_algo.h:4859:18:   required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = long long int]'
boxes.cpp:8:24:   required from here
/usr/include/c++/10/bits/stl_algo.h:1849:3: error: no type named 'value_type' in 'struct std::iterator_traits<long long int>'
 1849 |   __val = _GLIBCXX_MOVE(*__i);
      |   ^~~~~
/usr/include/c++/10/bits/stl_algo.h:1851:8: error: invalid type argument of unary '*' (have 'long long int')
 1851 |        *__first = _GLIBCXX_MOVE(__val);
      |        ^~~~~~~~
/usr/include/c++/10/bits/stl_algo.h:1849:3: error: no type named 'value_type' in 'struct std::iterator_traits<long long int>'
 1849 |   __val = _GLIBCXX_MOVE(*__i);
      |   ^~~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:71,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from boxes.cpp:1:
/usr/include/c++/10/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_less_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = long long int; _Iterator2 = long long int]':
/usr/include/c++/10/bits/stl_algo.h:82:17:   required from 'void std::__move_median_to_first(_Iterator, _Iterator, _Iterator, _Iterator, _Compare) [with _Iterator = long long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
/usr/include/c++/10/bits/stl_algo.h:1924:34:   required from '_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = long long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
/usr/include/c++/10/bits/stl_algo.h:1958:38:   required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = long long int; _Size = long long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
/usr/include/c++/10/bits/stl_algo.h:1974:25:   required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = long long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
/usr/include/c++/10/bits/stl_algo.h:4859:18:   required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = long long int]'
boxes.cpp:8:24:   required from here
/usr/include/c++/10/bits/predefined_ops.h:43:16: error: invalid type argument of unary '*' (have 'long long int')
   43 |       { return *__it1 < *__it2; }
      |                ^~~~~~
/usr/include/c++/10/bits/predefined_ops.h:43:25: error: invalid type argument of unary '*' (have 'long long int')
   43 |       { return *__it1 < *__it2; }
      |                         ^~~~~~
In file included from /usr/include/c++/10/bits/stl_algo.h:61,
                 from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from boxes.cpp:1:
/usr/include/c++/10/bits/stl_heap.h: In instantiation of 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = long long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]':
/usr/include/c++/10/bits/stl_algo.h:1666:23:   required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = long long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
/usr/include/c++/10/bits/stl_algo.h:1937:25:   required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = long long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
/usr/include/c++/10/bits/stl_algo.h:1953:27:   required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = long long int; _Size = long long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
/usr/include/c++/10/bits/stl_algo.h:1974:25:   required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = long long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
/usr/include/c++/10/bits/stl_algo.h:4859:18:   required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = long long int]'
boxes.cpp:8:24:   required from here
/usr/include/c++/10/bits/stl_heap.h:343:4: error: no type named 'value_type' in 'struct std::iterator_traits<long long int>'
  343 |    _ValueType;
      |    ^~~~~~~~~~
/usr/include/c++/10/bits/stl_heap.h:345:4: error: no type named 'difference_type' in 'struct std::iterator_traits<long long int>'
  345 |    _DistanceType;
      |    ^~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_heap.h: In instantiation of 'void std::__pop_heap(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = long long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]':
/usr/include/c++/10/bits/stl_algo.h:1669:19:   required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = long long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
/usr/include/c++/10/bits/stl_algo.h:1937:25:   required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = long long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
/usr/include/c++/10/bits/stl_algo.h:1953:27:   required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = long long int; _Size = long long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
/usr/include/c++/10/bits/stl_algo.h:1974:25:   required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = long long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
/usr/include/c++/10/bits/stl_algo.h:4859:18:   required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = long long int]'
boxes.cpp:8:24:   required from here
/usr/include/c++/10/bits/stl_heap.h:257:2: error: no type named 'value_type' in 'struct std::iterator_traits<long long int>'
  257 |  _ValueType;
      |  ^~~~~~~~~~
/usr/include/c++/10/bits/stl_heap.h:259:2: error: no type named 'difference_type' in 'struct std::iterator_traits<long long int>'
  259 |  _DistanceType;
      |  ^~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_heap.h:262:7: error: invalid type argument of unary '*' (have 'long long int')
  262 |       *__result = _GLIBCXX_MOVE(*__first);
      |       ^~~~~~~~~
In file included from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from boxes.cpp:1:
/usr/include/c++/10/bits/stl_heap.h:262:19: error: invalid type argument of unary '*' (have 'long long int')
  262 |       *__result = _GLIBCXX_MOVE(*__first);
      |                   ^~~~~~~~~~~~~