#include <bits/stdc++.h>
#define ll long long
using namespace std;
ifstream in("in.in");
ofstream out("out.out");
const int nmax = 2005;
const int P = 1000000007;
ll dp[nmax];
int solve(int N, int K, int* S) {
for (int i = 1; i <= N; i++) dp[i] = LLONG_MAX;
for (int i = 1; i <= N; i++) {
int maxSoFar = -1;
for (int j = i - 1; j >= 0 && j >= i - K; j--) {
maxSoFar = max(maxSoFar, S[j]);
dp[i] = min(dp[i], (dp[j] + maxSoFar));
}
}
ll put23 = 1;
ll sum = 0;
for (int 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);
}
Compilation message
/usr/bin/ld: /tmp/ccyXZ6iX.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccrkIKNV.o:peru.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status