单调队列
#include <iostream>
#include <cstdio>
using namespace std;
int n, l, r, dp[400005], a[200005], q[200005], hea, tai;
//dp[i] = max{dp[k]} + w[i] | i-r<=k<=i-l
int main(){
cin>>n>>l>>r;
for(int i=0; i<=n; i++) scanf("%d", &a[i]);
for(int i=l; i<=n; i++){
while(hea<=tai && q[hea]<i-r) hea++;//过期了
while(hea<=tai && dp[q[tai]]<dp[i-l]) tai--;//准备放进去i-l的
q[++tai] = i-l;//这才更新i-l的
dp[i] = dp[q[hea]] + a[i];
}
int maxn=0;
for(int i=n-r+1; i<=n; i++) maxn = max(maxn, dp[i]);
cout<<maxn<<endl;
return 0;
}