#include "peru.h"
#include <string.h>
#define N 2500000
#define MD 1000000007
#define X 23
long long min(long long a, long long b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
int solve(int n, int k, int *aa) {
static long long dp[N + 1];
int i, j, a, ans;
memset(dp, 0x3f, (n + 1) * sizeof *dp), dp[0] = 0;
for (i = 0; i < n; i++) {
a = 0;
for (j = i; j < n && j - i < k; j++) {
a = max(a, aa[j]);
dp[j + 1] = min(dp[j + 1], dp[i] + a);
}
}
ans = 0;
for (i = 0; i <= n; i++)
ans = ((long long) ans * X + dp[i] % MD) % MD;
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
0 ms |
340 KB |
Output is correct |
15 |
Correct |
572 ms |
9192 KB |
Output is correct |
16 |
Correct |
466 ms |
9192 KB |
Output is correct |
17 |
Correct |
292 ms |
9192 KB |
Output is correct |
18 |
Correct |
311 ms |
9192 KB |
Output is correct |
19 |
Correct |
387 ms |
9200 KB |
Output is correct |
20 |
Execution timed out |
853 ms |
9188 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
572 ms |
9192 KB |
Output is correct |
2 |
Correct |
466 ms |
9192 KB |
Output is correct |
3 |
Correct |
292 ms |
9192 KB |
Output is correct |
4 |
Correct |
311 ms |
9192 KB |
Output is correct |
5 |
Correct |
387 ms |
9200 KB |
Output is correct |
6 |
Execution timed out |
853 ms |
9188 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |