Submission #1201587

#TimeUsernameProblemLanguageResultExecution timeMemory
1201587Joon_YorigamiBoxes with souvenirs (IOI15_boxes)C++20
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <algorithm> #include <cmath> using namespace std; long long delivery(int N, int K, int L, int v[]){ //N is the number of teams that need their gifts //K is the carrying capacity //L is the number of nodes (ex. L = 8 gives us: 0,1,2,3,4,5,6,7) //v[] is an array vector<int> team_pos; team_pos.push_back(-1); for(int i = 0; i<N; i++){ team_pos.push_back(v[i]); } vector<int> cw(N+5, -1); vector<int> ccw(N+5, -1); cw[0] = 0; ccw[0] = 0; sort(team_pos.begin(), team_pos.end()); //----- ACCOUNT FOR DEFAULT FIRST //cw[i] = minimum total distance to DELIVER FIRST i GIFTS via CW //ccw[i] = minimum total distance to DELIVER FIRST i GITS via CCW for(int i = 1; i<=N; i++){ cw[i] = 2*team_pos[i]; ccw[i] = 2 * (L - team_pos[N - i + 1]); } //------ ACCOUNT FOR CAPACITY //cout << "ACCOUNT FOR CAPACITY\n"; for (int i = K+1; i <= N; i++){ //cout << i << " " << i-K << "\n"; cw[i] += cw[i-K]; } for (int i = 0; i <= N-K; i++){ //cout << N-i << " " << N-(i+K) << "\n"; ccw[N-i] += ccw[N-(i+K)]; } //print /*for(int i =0 ; i<cw.size(); i++){ cout << "cw[" << i << "] = " << cw[i] << "\n"; } cout << "\n"; for(int i =0 ; i<cw.size(); i++){ cout << "ccw[" << i << "] = " << ccw[i] << "\n"; }*/ //cout << "\n"; long long no_full = 1e18; long long yes_full = 1e18; for(int i = 0; i<=N; i++){ no_full = min(no_full, cw[i] + ccw[N-i]); //cout << i << " " << no_full << "\n"; } //cout << "\n"; for(int i = 0 ; i+K <= N; i++){ yes_full = min(yes_full, cw[i] + L + ccw[N-(i+K)]); //cout << i << " " << yes_full << "\n"; } //cout << no_full << " " << yes_full << "\n"; //cout << min(no_full, yes_full) << "\n"; return min(no_full, yes_full); } /* int main(){ int n; int k; int l; cin >> n >> k >> l; int v[n]; for(int i = 0; i<n; i++){ int x; cin >> x; v[i] = x; } delivery(n,k,l,v); }*/

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:64:22: error: no matching function for call to 'min(long long int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   64 |         no_full = min(no_full, cw[i] + ccw[N-i]);
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/char_traits.h:39,
                 from /usr/include/c++/11/ios:40,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from boxes.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
boxes.cpp:64:22: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   64 |         no_full = min(no_full, cw[i] + ccw[N-i]);
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/char_traits.h:39,
                 from /usr/include/c++/11/ios:40,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from boxes.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
boxes.cpp:64:22: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   64 |         no_full = min(no_full, cw[i] + ccw[N-i]);
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from boxes.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3449:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3449 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3449:5: note:   template argument deduction/substitution failed:
boxes.cpp:64:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   64 |         no_full = min(no_full, cw[i] + ccw[N-i]);
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from boxes.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3455:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3455 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3455:5: note:   template argument deduction/substitution failed:
boxes.cpp:64:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   64 |         no_full = min(no_full, cw[i] + ccw[N-i]);
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
boxes.cpp:69:24: error: no matching function for call to 'min(long long int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   69 |          yes_full = min(yes_full, cw[i] + L + ccw[N-(i+K)]);
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/char_traits.h:39,
                 from /usr/include/c++/11/ios:40,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from boxes.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
boxes.cpp:69:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   69 |          yes_full = min(yes_full, cw[i] + L + ccw[N-(i+K)]);
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/char_traits.h:39,
                 from /usr/include/c++/11/ios:40,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from boxes.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
boxes.cpp:69:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   69 |          yes_full = min(yes_full, cw[i] + L + ccw[N-(i+K)]);
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from boxes.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3449:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3449 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3449:5: note:   template argument deduction/substitution failed:
boxes.cpp:69:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   69 |          yes_full = min(yes_full, cw[i] + L + ccw[N-(i+K)]);
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from boxes.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3455:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3455 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3455:5: note:   template argument deduction/substitution failed:
boxes.cpp:69:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   69 |          yes_full = min(yes_full, cw[i] + L + ccw[N-(i+K)]);
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~