이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "peru.h"
#include <bits/stdc++.h>
using namespace std;
const int md = 1e9 + 7;
int add(int x, int y) {
return x + y < md ? x + y : x + y - md;
}
int mul(int x, int y) {
return x * 1LL * y % md;
}
int solve(int n, int k, int* v) {
const long long inf = (long long) 1e18;
vector<long long> dp(n, inf);
for (int i = 0; i < n; i++) {
int mx = 0;
for (int j = i; j >= 0; j--) {
if (i - j + 1 > k) {
break;
}
mx = max(mx, v[j]);
dp[i] = min(dp[i], (j == 0 ? 0LL : dp[j - 1]) + mx);
}
}
int res = 0;
int pw = 1;
for (int i = n - 1; i >= 0; i--) {
dp[i] %= md;
res = add(res, mul(pw, dp[i]));
pw = mul(pw, 23);
}
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... |