Loj 514 模拟只会猜题意 Posted on 2019-08-14 | Views: 原以为此题必有高论,结果直接 $O(n^2)$ 暴力预处理答案就可以了. 1234567891011121314151617181920212223242526272829303132333435#include<bits/stdc++.h>using namespace std;typedef long long ll;inline int read(){ int out=0,fh=1; char jp=getchar(); while ((jp>'9'||jp<'0')&&jp!='-') jp=getchar(); if (jp=='-') fh=-1,jp=getchar(); while (jp>='0'&&jp<='9') out=out*10+jp-'0',jp=getchar(); return out*fh;}const int inf=1e9;const int MAXN=1e4+10;int n,m,ans[MAXN],a[MAXN];int main(){ n=read(),m=read(); for(int i=1;i<=n;++i) { a[i]=read()+a[i-1]; ans[i]=-inf; } for(int i=1;i<=n;++i) for(int j=i;j<=n;++j) ans[j-i+1]=max(ans[j-i+1],a[j]-a[i-1]); for(int i=n-1;i>=1;--i) ans[i]=max(ans[i+1],ans[i]); for(int i=1;i<=m;++i) printf("%d\n",ans[read()]); return 0;}