记录编号 |
599550 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[東方S1] 琪露诺 |
最终得分 |
100 |
用户昵称 |
LikableP |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.203 s |
提交时间 |
2025-03-21 21:21:40 |
内存使用 |
9.77 MiB |
显示代码纯文本
#include <cstdio>
#include <cstring>
const int MAXN = 2e6 + 10;
int n, L, R;
int a[MAXN];
int f[MAXN], pre[MAXN];
int q[MAXN], head = 1, tail = 0;
int ed;
void print(int i) {
if (pre[i]) print(pre[i]);
printf("%d ", i);
}
int main() {
freopen("iceroad.in", "r", stdin);
freopen("iceroad.out", "w", stdout);
memset(f, 0x80, sizeof f), f[0] = 0;
scanf("%d %d %d", &n, &L, &R);
for (int i = 0; i <= n; ++i) {
scanf("%d", &a[i]);
}
for (int i = L; i <= n; ++i) {
while (head <= tail && q[head] < i - R) head++;
while (head <= tail && f[q[tail]] < f[i - L]) tail--;
q[++tail] = i - L;
pre[i] = q[head];
f[i] = f[q[head]] + a[i];
if (i >= n - R + 1) {
if (f[i] > f[ed]) {
ed = i;
}
}
}
printf("%d\n0 ", f[ed]);
print(ed);
printf("-1\n");
return 0;
}