이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
#define ll int
#include "peru.h"
using namespace std;
const ll nmax = 2005;
const ll P = 1000000007;
ll dp[nmax];
int32_t solve(int32_t N, int32_t K, int32_t* S) {
for (ll i = 1; i <= N; i++) dp[i] = LLONG_MAX;
for (ll i = 1; i <= N; i++) {
ll maxSoFar = -1;
for (ll j = i - 1; j >= 0 && j >= i - K; j--) {
maxSoFar = max(maxSoFar, 1LL * S[j]);
dp[i] = min(dp[i], (dp[j] + maxSoFar));
}
}
int dhs=1, ans=0;
for(int i=N; i>=1; i--)
{
ans+=(dp[i]%P*dhs)%P;
ans%=P;
dhs=(dhs*23)%P;
}
return ans;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |