lraM416 @ 2024-07-24 11:14:27
暴力dp但是hack第一个没过。
#include<bits/stdc++.h>
using namespace std;
int dp[200005],n,l,r,a[200005],s=-20220517,t;
signed main(){
cin>>n>>l>>r;
for(int i=0;i<=n;i++) cin>>a[i],dp[i]=-20220517;
dp[0]=0;
for(int i=0;i<=n;i++)
for(int j=i+l;j<=i+r;j++)
if(j>n) break;
else dp[j]=max(dp[j],dp[i]+a[j]),s=max(s,dp[j]);
cout<<s;
return 0;
}
by lraM416 @ 2024-07-24 11:16:32
开o2可以喜提100pts
by lraM416 @ 2024-07-24 12:37:27
@Dream__Sky 666我怎么你了
by Dream__Sky @ 2024-07-24 12:39:10
@lraM416 难道你不知道这题是单调队列优化dp 吗????菜就多练
by lraM416 @ 2024-07-24 12:40:45
@Dream__Sky 我写暴力怎么你了???????????????????
by Dream__Sky @ 2024-07-24 12:42:12
@lraM416 那你还发帖子问???????????这么喜欢对线????
by lraM416 @ 2024-07-24 12:43:19
@Dream__Sky 我问你我哪里写错了/fn
by Dream__Sky @ 2024-07-24 12:44:08
@lraM416 哦,那我帮你看看,不过您不是过了吗
by lraM416 @ 2024-07-24 12:44:30
@Dream__Sky hack wa了啊
by Dream__Sky @ 2024-07-24 12:45:00
dp初始化要为负无穷
记录答案的标量要赋值成负无穷
如果这个点不能到达不记录答案
如果以前把dp初始化成-1,那么一定要把所有的判断是不是能到的都改成负无穷
by lraM416 @ 2024-07-24 12:46:06
@Dream__Sky tql%%%(我比你大还比你菜,该afo了