제출 #1086931

#제출 시각아이디문제언어결과실행 시간메모리
1086931codexistent선물상자 (IOI15_boxes)C++14
컴파일 에러
0 ms0 KiB
// Key to solution lies in the fact that you cannot have more than 1 full-circle trip. // PROOF: Assume you have 2 full-circle trips. Then you travel 2L time and deliver >= 2K souvenirs. // But we can easily just deliver the first k souvenirs(from clockwise direction) in 2 * x time going // clockwise and deliver the first k souvenirs(from counter-clockwise direction) in at most 2 * (l - x) // time going counter-clockwise, which is just as good if not better. #include <bits/stdc++.h> #include "boxes.h" using namespace std; #define MAXN 10000005 #define FOR(i, a, b) for(long long i = a; i <= b; i++) #define RFOR(i, a, b) for(long long i = a; i >= b; i--) long long dp_cw[MAXN], dp_ccw[MAXN], r = __LONG_LONG_MAX__; long long delivery(int N, int K, int L, int p[]) { dp_cw[0] = dp_ccw[N + 1] = 0; FOR(i, 1, N) dp_cw[i] = dp_cw[max((long long)0, (long long)i - K)] + 2 * p[i - 1]; RFOR(i, N, 1) dp_ccw[i] = dp_ccw[min(N + 1, i + K)] + 2 * (L + 1 - p[i - 1]); FOR(i, 0, N) r = min(r, dp_cw[i] + dp_ccw[i + 1]); if(N >= K) FOR(i, 0, N) r = min(r, dp_cw[i] + dp_ccw[i + K + 1]); return r; }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:18:54: error: no matching function for call to 'min(int, long long int)'
   18 |     RFOR(i, N, 1) dp_ccw[i] = dp_ccw[min(N + 1, i + K)] + 2 * (L + 1 - p[i - 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:6:
/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:18:54: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   18 |     RFOR(i, N, 1) dp_ccw[i] = dp_ccw[min(N + 1, i + K)] + 2 * (L + 1 - p[i - 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:6:
/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:18:54: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   18 |     RFOR(i, N, 1) dp_ccw[i] = dp_ccw[min(N + 1, i + K)] + 2 * (L + 1 - p[i - 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:6:
/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:18:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   18 |     RFOR(i, N, 1) dp_ccw[i] = dp_ccw[min(N + 1, i + K)] + 2 * (L + 1 - p[i - 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:6:
/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:18:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   18 |     RFOR(i, N, 1) dp_ccw[i] = dp_ccw[min(N + 1, i + K)] + 2 * (L + 1 - p[i - 1]);
      |                                                      ^