Submission #493479

# Submission time Handle Problem Language Result Execution time Memory
493479 2021-12-11T15:18:33 Z Jeff12345121 Peru (RMI20_peru) C++17
0 / 100
2 ms 340 KB
#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, 1LL * 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);
}
*/
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -