Submission #522594

#TimeUsernameProblemLanguageResultExecution timeMemory
522594cig32선물상자 (IOI15_boxes)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #include "boxes.h" #define int long long long long delivery(int32_t n, int32_t k, int32_t l, int32_t p[]) { int l[n+1], r[n+1], ans = 1e18; for(int i=0; i<=n; i++) l[i] = r[i] = 1e18; l[0] = r[n] = 0; for(int i=1; i<=n; i++) { l[i] = l[max(i-k, 0ll)] + 2 * p[i-1], r[n-i] = r[min(n-i+k, n)] - 2 * p[n-i] + 2 * l; } for(int i=0; i<=n; i++) ans = min(ans, l[i] + min(r[i], r[min(i+k, n)] + 1)); return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int32_t, int32_t, int32_t, int32_t*)':
boxes.cpp:6:7: error: declaration of 'long long int l [(n + 1)]' shadows a parameter
    6 |   int l[n+1], r[n+1], ans = 1e18;
      |       ^
boxes.cpp:5:50: note: 'int32_t l' previously declared here
    5 | long long delivery(int32_t n, int32_t k, int32_t l, int32_t p[]) {
      |                                          ~~~~~~~~^
boxes.cpp:11:28: error: no matching function for call to 'min(long long int, int32_t&)'
   11 |     r[n-i] = r[min(n-i+k, n)] - 2 * p[n-i] + 2 * l;
      |                            ^
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: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:11:28: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int32_t' {aka 'int'})
   11 |     r[n-i] = r[min(n-i+k, n)] - 2 * p[n-i] + 2 * l;
      |                            ^
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: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:11:28: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int32_t' {aka 'int'})
   11 |     r[n-i] = r[min(n-i+k, n)] - 2 * p[n-i] + 2 * l;
      |                            ^
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: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:11:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   11 |     r[n-i] = r[min(n-i+k, n)] - 2 * p[n-i] + 2 * l;
      |                            ^
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: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:11:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   11 |     r[n-i] = r[min(n-i+k, n)] - 2 * p[n-i] + 2 * l;
      |                            ^
boxes.cpp:11:48: error: invalid operands of types 'int' and 'long long int [(n + 1)]' to binary 'operator*'
   11 |     r[n-i] = r[min(n-i+k, n)] - 2 * p[n-i] + 2 * l;
      |                                              ~ ^ ~
      |                                              |   |
      |                                              int long long int [(n + 1)]
boxes.cpp:13:71: error: no matching function for call to 'min(long long int, int32_t&)'
   13 |   for(int i=0; i<=n; i++) ans = min(ans, l[i] + min(r[i], r[min(i+k, n)] + 1));
      |                                                                       ^
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: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:13:71: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int32_t' {aka 'int'})
   13 |   for(int i=0; i<=n; i++) ans = min(ans, l[i] + min(r[i], r[min(i+k, n)] + 1));
      |                                                                       ^
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: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:13:71: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int32_t' {aka 'int'})
   13 |   for(int i=0; i<=n; i++) ans = min(ans, l[i] + min(r[i], r[min(i+k, n)] + 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:1:
/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:13:71: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   13 |   for(int i=0; i<=n; i++) ans = min(ans, l[i] + min(r[i], r[min(i+k, n)] + 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:1:
/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:13:71: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   13 |   for(int i=0; i<=n; i++) ans = min(ans, l[i] + min(r[i], r[min(i+k, n)] + 1));
      |                                                                       ^
boxes.cpp:5:50: warning: unused parameter 'l' [-Wunused-parameter]
    5 | long long delivery(int32_t n, int32_t k, int32_t l, int32_t p[]) {
      |                                          ~~~~~~~~^