This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
int mx = 0;
for (int i = 0; i < k; i++){
mx = max(mx, v[i]);
dp[i] = mx;
}
for (int i = k; i < n; i++){
int mx = 0;
for (int j = i - k + 1; j <= i; j++){
mx = max(mx, v[j]);
}
dp[i] = dp[i - k] + mx;
}
int64 rs = 0;
for (int i = 0; i < n; i++){
rs = (rs + dp[i] * pw[i]) % mod;
}
return rs;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |