Submission #848914

# Submission time Handle Problem Language Result Execution time Memory
848914 2023-09-13T17:33:40 Z TahirAliyev Peru (RMI20_peru) C++17
18 / 100
541 ms 9432 KB
#include "peru.h"
#include <bits/stdc++.h>

#define ll long long
#define oo 1e17

using namespace std;

const int MAX = 2002, MOD = 1e9 + 7;
int arr[MAX];
ll dp[MAX];

int solve(int n, int k, int* v){
    for(int i = 1; i <= n; i++){
        dp[i] = oo;
    }
    for(int i = 0; i < n; i++){
        arr[i + 1] = v[i];
    }
    for(int i = 1; i <= n; i++){
        int m = 0;
        for(int j = 1; j <= k; j++){
            if(i - j < 0) break;
            m = max(arr[i - j + 1], m);
            dp[i] = min(dp[i - j] + m, dp[i]);
        }
    }
    ll ans = 0;
    ll p = 1;
    for(int i = n; i >= 1; i--){
        ans += dp[i] % MOD * p % MOD;
        ans %= MOD;
        p *= 23;
        p %= MOD;
    }
    return ans;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Runtime error 541 ms 9432 KB Execution killed with signal 11
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 541 ms 9432 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -