#include <bits/stdc++.h>
#include "peru.h"
#ifdef MINA
#include "grader.cpp"
#endif
using namespace std;
#define ll long long
const int N = 2'500'005, mod = 1e9 + 7;
const ll inf = 1e18;
ll dp[N], a[N];
int solve(int n, int k, int *v) {
for (int i = 0; i < n; i++) {
a[i + 1] = v[i];
}
for (int i = 1; i <= n; i++) {
dp[i] = inf;
ll c = 0;
for (int j = i; j > max(0, i - k); j--) {
c = max(c, a[j]);
dp[i] = min(dp[i], dp[j - 1] + c);
}
}
int ans = 0;
ll pw = 1;
for (int i = n; i >= 1; i--) {
ans += pw * (dp[i] % mod) % mod;
ans %= mod;
pw = pw * 23 % mod;
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
481 ms |
12884 KB |
Output is correct |
16 |
Correct |
392 ms |
17128 KB |
Output is correct |
17 |
Correct |
228 ms |
16980 KB |
Output is correct |
18 |
Correct |
254 ms |
17132 KB |
Output is correct |
19 |
Correct |
319 ms |
17128 KB |
Output is correct |
20 |
Execution timed out |
631 ms |
16976 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
481 ms |
12884 KB |
Output is correct |
2 |
Correct |
392 ms |
17128 KB |
Output is correct |
3 |
Correct |
228 ms |
16980 KB |
Output is correct |
4 |
Correct |
254 ms |
17132 KB |
Output is correct |
5 |
Correct |
319 ms |
17128 KB |
Output is correct |
6 |
Execution timed out |
631 ms |
16976 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |