题目链接
测试记录
#include<bits/stdc++.h>
#define ll long long
#define INF 0x7f7f7f7f
#define lowbit(x) x & -x
#define re register
using namespace std;
int n;
int l,r;
int a[200005];
int ans[200005];
int que[200005];
int head=1,tail=1;
int maxn=-INF;
int i,j;
int main(int argc,char** argv)
{
cin >>n;
cin >>l>>r;
memset(ans,128,sizeof(ans));
ans[0]=0;
for (i=0;i<=n;i++)
cin >>a[i];
for (i=l;i<=n;i++)
{
while (ans[i-l]>=ans[que[tail]]&&tail>=head)
tail--;
que[++tail]=i-l;
while (que[head]+r<i)
head++;
ans[i]=ans[que[head]]+a[i];
if (i+r>n)
maxn=max(maxn,ans[n-i+1]);
}
cout <<maxn<<endl;
return 0;
}