Submission #493478

#TimeUsernameProblemLanguageResultExecution timeMemory
493478Jeff12345121Peru (RMI20_peru)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define ll long long #include "peru.h" using namespace std; const ll nmax = 2500000; const ll P = 1000000007; ll dp[nmax]; int solve(int N, int K, int* S) { for (ll i = 1; i <= N; i++) dp[i] = LLONG_MAX; for (ll i = 1; i <= N; i++) { ll maxSoFar = -1; for (ll j = i - 1; j >= 0 && j >= i - K; j--) { maxSoFar = max(maxSoFar, S[j]); dp[i] = min(dp[i], (dp[j] + maxSoFar)); } } ll put23 = 1; ll sum = 0; for (ll i = N; i >= 1; i--) { sum = (sum + dp[i] * put23 % P) % P; put23 = ( put23 * 23 ) % P; } return sum; } /*int s[nmax]; int main() { int n,k; in >> n >> k; for (int i = 0; i < n; i++) in >> s[i]; out << solve(n , k , s); } */

Compilation message (stderr)

peru.cpp: In function 'int solve(int, int, int*)':
peru.cpp:14:42: error: no matching function for call to 'max(long long int&, int&)'
   14 |             maxSoFar = max(maxSoFar, S[j]);
      |                                          ^
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 peru.cpp:1:
/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:
peru.cpp:14:42: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   14 |             maxSoFar = max(maxSoFar, S[j]);
      |                                          ^
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 peru.cpp:1:
/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:
peru.cpp:14:42: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   14 |             maxSoFar = max(maxSoFar, S[j]);
      |                                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from peru.cpp:1:
/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:
peru.cpp:14:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   14 |             maxSoFar = max(maxSoFar, S[j]);
      |                                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from peru.cpp:1:
/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:
peru.cpp:14:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   14 |             maxSoFar = max(maxSoFar, S[j]);
      |                                          ^