Submission #645888

# Submission time Handle Problem Language Result Execution time Memory
645888 2022-09-28T08:48:11 Z Vanilla Peru (RMI20_peru) C++17
0 / 100
1 ms 340 KB
#include <bits/stdc++.h>
#include "peru.h"
using namespace std;
typedef long long int64;
const int maxn = 2e3 + 2;
const int64 mod = 1e9 + 7;
int64 dp [maxn];
int64 pw [maxn];

int solve(int n, int k, int* v){
    pw[n-1] = 1;
    for (int i = n - 2; i >= 0; i--){
        pw[i] = (pw[i + 1] * 23) % mod;
    }
    for (int i = 0; i < n; i++){
        int mx = 0;
        dp[i] = 1e18;
        for (int j = i; j >= max(0, i - k + 1); j--){
            mx = max(mx, v[j]);
            dp[i] = min(dp[i], (j ? dp[j - 1] : 0) + mx);
        }
        dp[i]%=mod;
        // dp[i] = dp[i - k] + mx;
    }
    int64 rs = 0;
    for (int i = 0; i < n; i++){
        rs = (rs + dp[i] * pw[i] % mod) % mod;
        // for (int j = 0; j < n - i - 1; j++){
        //     dp[i] = (dp[i] * 23) % mod;
        // }
        // cout << dp[i] << " ";
        // rs = (rs + dp[i]) % mod;
    }
    // cout << "\n";
    return rs;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -