首页 > 代码库 > zoj 3714 Java Beans

zoj 3714 Java Beans

#include<stdio.h>#include<string.h>#include<math.h>#include<iostream>#include<algorithm>#include<queue>#include<stack>#define mem(a,b) memset(a,b,sizeof(a))#define ll __int64#define MAXN 1000#define INF 0x7ffffff#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;int a[300];int main(){    int t,n,m;    int i,j;    scanf("%d",&t);    while(t--)    {        scanf("%d%d",&n,&m);        for(i=1;i<=n;i++)            scanf("%d",&a[i]);        int maxx=0;        for(i=1;i<=n;i++)        {            int sum=0;            for(j=i;j<=m+i-1;j++)            {                int temp=j;                if(j>n) temp%=n;                sum+=a[temp];            }            if(maxx<sum) maxx=sum;        }        printf("%d\n",maxx);    }    return 0;}