Submission #858802

# Submission time Handle Problem Language Result Execution time Memory
858802 2023-10-09T08:12:02 Z iulia_morariu Peru (RMI20_peru) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include <peru.h>

using namespace std;

#define Mod 1000000007
int solve ( int n, int k, int* v ){

    long long int dp[n + 1];
    dp[0] = 0;
    for(int i = 1; i <= n; i++){
        long long int maxi = v[i - 1];
        dp[i] = LLONG_MAX;
        //cout << "i = " << i << "   maxi = " << maxi << endl;
        for(int j = i - 1; j >= 0 && i - j <= k; j--){
            dp[i] = min( dp[i], dp[j] + maxi );
            //cout << "  -- > j = " << j << " dp[j] = " << dp[j] << "  maxi = " << maxi << endl;
            maxi = max( v[j - 1], maxi );
        }
    }
/*
    cout << "dp : ";
    for(int i = 1; i <= n; i++) cout << dp[i] << " ";
    cout << endl;
*/
    long long int sum = 0;
    long long int p = 1;
    for(int i = n; i > 0; i--){
        sum += (p * dp[i]) % Mod;
        p *= 23;
        p %= Mod;
    }
    return sum;

}

Compilation message

peru.cpp: In function 'int solve(int, int, int*)':
peru.cpp:18:40: error: no matching function for call to 'max(int&, long long int&)'
   18 |             maxi = max( v[j - 1], maxi );
      |                                        ^
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:18:40: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   18 |             maxi = max( v[j - 1], maxi );
      |                                        ^
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:18:40: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   18 |             maxi = max( v[j - 1], maxi );
      |                                        ^
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:18:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   18 |             maxi = max( v[j - 1], maxi );
      |                                        ^
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:18:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   18 |             maxi = max( v[j - 1], maxi );
      |                                        ^