제출 #642058

#제출 시각아이디문제언어결과실행 시간메모리
642058QwertyPiBoxes with souvenirs (IOI15_boxes)C++14
컴파일 에러
0 ms0 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; long long dp_l[10000001]; long long dp_r[10000001]; long long delivery(int N, int K, int L, int p[]) { for(int i = 0; i < N; i++){ dp_l[i + 1] = dp_l[max(0LL, i + 1 - K)] + min(L, p[i] * 2); } for(int i = N; i >= 1; i--){ dp_r[i] = dp_r[min(N + 1, i + K)] + min(L, (L - p[i - 1]) * 2); } int ans = 1LL << 60; for(int l = 0; l <= N; l++){ ans = min(ans, dp_l[l] + dp_r[l + 1]); } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:12:40: error: no matching function for call to 'max(long long int, int)'
   12 |   dp_l[i + 1] = dp_l[max(0LL, i + 1 - K)] + min(L, p[i] * 2);
      |                                        ^
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/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from boxes.cpp:3:
/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:12:40: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   12 |   dp_l[i + 1] = dp_l[max(0LL, i + 1 - K)] + min(L, p[i] * 2);
      |                                        ^
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/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from boxes.cpp:3:
/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:12:40: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   12 |   dp_l[i + 1] = dp_l[max(0LL, i + 1 - K)] + min(L, p[i] * 2);
      |                                        ^
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:3:
/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:12:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   12 |   dp_l[i + 1] = dp_l[max(0LL, i + 1 - K)] + min(L, p[i] * 2);
      |                                        ^
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:3:
/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:12:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   12 |   dp_l[i + 1] = dp_l[max(0LL, i + 1 - K)] + min(L, p[i] * 2);
      |                                        ^
boxes.cpp:17:16: warning: overflow in conversion from 'long long int' to 'int' changes value from '1152921504606846976' to '0' [-Woverflow]
   17 |  int ans = 1LL << 60;
      |            ~~~~^~~~~
boxes.cpp:19:39: error: no matching function for call to 'min(int&, long long int)'
   19 |   ans = min(ans, dp_l[l] + dp_r[l + 1]);
      |                                       ^
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/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from boxes.cpp:3:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
boxes.cpp:19:39: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   19 |   ans = min(ans, dp_l[l] + dp_r[l + 1]);
      |                                       ^
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/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from boxes.cpp:3:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
boxes.cpp:19:39: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   19 |   ans = min(ans, dp_l[l] + dp_r[l + 1]);
      |                                       ^
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:3:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
boxes.cpp:19:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   19 |   ans = min(ans, dp_l[l] + dp_r[l + 1]);
      |                                       ^
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:3:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
boxes.cpp:19:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   19 |   ans = min(ans, dp_l[l] + dp_r[l + 1]);
      |                                       ^