题意大致为求两个长度为k的区间和最大,如果枚举第一个区间的起点L1,则只需要在[L1+k,n-k+1]中找一个位置X满足[X,X+k-1]的和最大。所以可以预处理:sum[i]表示[i,i+k-1]的值,Max[i]表示[i,n-k+1]中的sum最大值。最后枚举起点L1,则答案为max(sum[L1]+Max[L1+k]) #include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 2e5+10; const ll inf = 1e18; ll a[maxn],p[maxn...