이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "peru.h"
#include <bits/stdc++.h>
#define ll long long
#define oo 1e16
using namespace std;
const int MAX = 2002, MOD = 1e9 + 7;
int arr[MAX];
ll dp[MAX];
int solve(int n, int k, int* v){
for(int i = 1; i <= n; i++){
dp[i] = oo;
}
for(int i = 0; i < n; i++){
arr[i + 1] = v[i];
}
for(int i = 1; i <= n; i++){
int m = 0;
for(int j = 1; j <= k; j++){
if(i - j < 0) break;
m = max(arr[i - j + 1], m);
dp[i] = min(dp[i - j] + m, dp[i]);
}
}
ll ans = 0;
ll p = 1;
for(int i = n; i >= 1; i--){
ans += dp[i] * p % MOD;
ans %= MOD;
p *= 23;
p %= MOD;
}
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... |