FanMingxuan @ 2024-02-08 22:01:06
#include<bits/stdc++.h>
using namespace std;
const int N = 11451419;
int a[N];
int f[N];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,l,r;
cin>>n>>l>>r;
n ++; //已经预先加一了
for(int i = 1; i <= n; ++ i) cin>>f[i];
deque<int> q;
for(int i = n + r + 1;i >= 1;-- i) {
// if(i + l <= n + 1){ //n + 1 能过
if(i + l <= n){ //n就会WA on #3其他正确
while(!q.empty() && f[q.back()] < f[i + l]) q.pop_back();
q.push_back(i + l);
}
while(!q.empty() && q.front() > i + r) q.pop_front();
if(!q.empty()) f[i] += f[q.front()];
}
cout<<f[1];
return 0;
}
58 3 22
0 480 333 559 795 -357 -331 29 -719 -527 621 954 -87 -350 -242 -391 -991 -626 -367 285 490 -62 366 251 282 446 597 -640 -115 357 -60 157 -380 -544 669 792 -250 -40 -989 860 780 578 30 224 116 -987 219 431 629 -266 -188 -478 322 699 907 -108 -373 -575 -107
正确输出:
6885
错误输出:
6778
by 0x3F @ 2024-02-08 22:11:45
@FanMingxuan
只要她下一步的位置编号大于
by FanMingxuan @ 2024-02-08 22:16:46
@0x3F 谢谢,没看题 orz
by FanMingxuan @ 2024-02-08 22:17:20
此帖结