Submission #993872

#TimeUsernameProblemLanguageResultExecution timeMemory
993872yellowtoadBoxes with souvenirs (IOI15_boxes)C++17
Compilation error
0 ms0 KiB
#include "boxes.h" #include <iostream> using namespace std; long long a[10000010], dp[10000010], dpp[10000010], minn = 1e18; long long delivery(int n, int k, int l, int p[]) { for (int i = 1; i <= n; i++) a[i] = p[i-1]; for (int i = 1; i <= n; i++) dp[i] = dp[max(0LL,i-k)]+a[i]*2; for (int i = n; i >= 1; i--) dpp[i] = dpp[min(n+1,i+k)]+(l-a[i])*2; for (int i = 0; i <= n; i++) minn = min(minn,dp[i]+dpp[i+1]); for (int i = 0; i <= n-k; i++) minn = min(minn,dp[i]+dpp[i+k+1]+l); return minn; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:7:53: error: no matching function for call to 'max(long long int, int)'
    7 |  for (int i = 1; i <= n; i++) dp[i] = dp[max(0LL,i-k)]+a[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/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from boxes.cpp:2:
/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:7:53: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
    7 |  for (int i = 1; i <= n; i++) dp[i] = dp[max(0LL,i-k)]+a[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/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from boxes.cpp:2:
/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:7:53: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
    7 |  for (int i = 1; i <= n; i++) dp[i] = dp[max(0LL,i-k)]+a[i]*2;
      |                                                     ^