이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "peru.h"
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int solve(int n, int k, int* v){
vector<long long> dp(n+1), p(n+1);
long long res=0;
p[0]=1;
for (int i=1; i<=n; i++) p[i]=(p[i-1]*23)%mod;
for (int i=1; i<=n; i++)
{
int mx=0;
dp[i]=LLONG_MAX;
for (int j=i; j>=max(i-k+1, 1); j--)
{
mx=max(mx, v[j-1]);
dp[i]=min(dp[i], dp[j-1]+mx);
}
res=(res+p[n-i]*dp[i])%mod;
//cout<<i<<' '<<dp[i]<<'\n';
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |