标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 6844 Accepted Submission(s): 2518
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #include<vector> using namespace std; const int INF=0x3f3f3f3f; #define mem(x,y) memset(x,y,sizeof(x)) #define SI(x) scanf("%d",&x) #define PI(x) printf("%d",x) #define SD(x) scanf("%lf",&x) #define P_ printf(" ") typedef long long LL; const int MAXN=100010; int m[MAXN]; int main(){ int T,N,K; SI(T); while(T--){ SI(N);SI(K); for(int i=1;i<=N;i++)SI(m[i]); int cur=0,ans=-INF,l,r; for(int i=1;i+K-1<=N;i++){ cur=0; for(int j=0;j<K;j++){ cur+=m[i+j]; if(cur>ans){ ans=cur; l=i;r=i+j; } } } printf("%d %d %d\n",ans,l,r); } return 0; }
标签:
原文地址:http://www.cnblogs.com/handsomecui/p/5205202.html