This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "peru.h"
#include <iostream>
using namespace std;
constexpr int NMAX = 2500005;
constexpr int MOD = 1e9 + 7;
typedef long long LL;
LL dp[NMAX];
int ans = 0;
int solve(int n, int k, int* v){
for (int i = 0; i < n; ++ i ) {
int Max_Effort = v[i];
dp[i] = 100000000000000000;
for (int j = i; j > max(0, i-k+1); -- j ) {
Max_Effort = max(Max_Effort, v[j]);
dp[i] = min(dp[i], dp[j-1] + 1LL * Max_Effort);
}
Max_Effort = max(Max_Effort, v[max(0, i-k+1)]);
if (i < k) dp[i] = min(dp[i], 1LL * Max_Effort);
else dp[i] = min(dp[i], dp[i-k] + 1LL * Max_Effort);
}
for (int i = 0; i < n; ++ i ) {
ans = (23LL * ans + dp[i]%MOD) % 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... |