Submission #858790

# Submission time Handle Problem Language Result Execution time Memory
858790 2023-10-09T07:49:17 Z iulia_morariu Peru (RMI20_peru) C++14
0 / 100
1 ms 348 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++){
        int maxi = v[i - 1];
        dp[i] = INT_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;

}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -