Submission #364025

#TimeUsernameProblemLanguageResultExecution timeMemory
364025wind_reaperBoxes with souvenirs (IOI15_boxes)C++17
Compilation error
0 ms0 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; #define dbg(x) cout << "[" << #x << ": " << x << "] "; long long delivery(int N, int k, int L, int p[]) { vector<int64_t> pref(N+2), suf(N+2), x(N+2); x[0] = 0; for(int i = 1; i <= N; i++) x[i] = p[i-1]; x[N+1] = L; pref[0] = 0; for(int i = 1; i <= N + 1; i++) pref[i] = (i > k ? 2*x[k*(i/k)] + x[i] : x[i]); suf[N+1] = 0; for(int i = N; i >= 0; --i) suf[i] = (N - i + 1 > k ? 2*(L - x[N - k*((N-i+1)/k) + 1]) + L - x[i] : L - x[i]); long long ans = 1e18; for(int i = 0; i < N+1; i++) ans = min(ans, pref[i] + suf[i+1] + L - x[i+1] + x[i]); return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:25:59: error: no matching function for call to 'min(long long int&, __gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type)'
   25 |      ans = min(ans, pref[i] + suf[i+1] + L - x[i+1] + x[i]);
      |                                                           ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from boxes.cpp:2:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  198 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:198:5: note:   template argument deduction/substitution failed:
boxes.cpp:25:59: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type' {aka 'long int'})
   25 |      ans = min(ans, pref[i] + suf[i+1] + L - x[i+1] + x[i]);
      |                                                           ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from boxes.cpp:2:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  246 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:246:5: note:   template argument deduction/substitution failed:
boxes.cpp:25:59: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type' {aka 'long int'})
   25 |      ans = min(ans, pref[i] + suf[i+1] + L - x[i+1] + x[i]);
      |                                                           ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:3444:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3444 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3444:5: note:   template argument deduction/substitution failed:
boxes.cpp:25:59: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   25 |      ans = min(ans, pref[i] + suf[i+1] + L - x[i+1] + x[i]);
      |                                                           ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
boxes.cpp:25:59: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   25 |      ans = min(ans, pref[i] + suf[i+1] + L - x[i+1] + x[i]);
      |                                                           ^