#include "peru.h"
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
const long long INF = 1e18;
long long a[2500005];
long long dp[2500005];
int solve(int n, int k, int* v)
{
a[0]=2e9+2;
for(int i=1;i<=n;i++)
{
a[i]=v[i-1];
dp[i]=INF;
long long mxm=0;
for(int j=i-1;j>=i-k;j--)
{
mxm = max(mxm, a[j+1]);
if(j==i-k || a[j]>mxm)
{
dp[i] = min(dp[i], dp[j]+mxm);
}
}
}
long long rez=0,put23=1;
for(int i=n;i>0;i--)
{
rez = (rez + put23*dp[i])%MOD;
put23 = put23*23LL%MOD;
}
return rez;
}
/*
8 3
3 2 9 8 7 11 3 4
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |