There are N little kids sitting in a circle, each of them are carrying some java beans in their hand. Their teacher want to select M kids who seated in M consecutive seats and collect java beans from them.

The teacher knows the number of java beans each kids has, now she wants to know the maximum number of java beans she can get from M consecutively seated kids. Can you help her?

Input

There are multiple test cases. The first line of input is an integer T indicating the number of test cases.

For each test case, the first line contains two integers N (1 ≤ N ≤ 200) and M (1 ≤ M ≤ N). Here N and M are defined in above description. The second line of each test case contains N integers Ci (1 ≤ Ci ≤ 1000) indicating number of java beans the ith kid have.

Output

For each test case, output the corresponding maximum java beans the teacher can collect.

Sample Input

2
5 2
7 3 1 3 9
6 6
13 28 12 10 20 75

Sample Output

16
158
 
题意:很简单,给出n,k,计算n个数中长度为k的最大和,而且其中没有负数,只需要注意这些数字组成的是一个环形
思路:数据很小,直接水过
 
#include <stdio.h>
#include <string.h> int main()
{
int t,n,k,i,j,a[405],sum,MAX;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&k);
for(i=1; i<=n; i++)
{
scanf("%d",&a[i]);
a[n+i] = a[i];
}
MAX = 0;
for(i=1; i<=n; i++)
{
sum = 0;
for(j = i; j<i+k; j++)
{
sum+=a[j];
}
if(sum>MAX)
MAX = sum;
}
printf("%d\n",MAX);
}
return 0;
}

ZOJ3714:Java Beans的更多相关文章

  1. 黑马程序员:Java基础总结----JavaBean 内省

    黑马程序员:Java基础总结 JavaBean 内省   ASP.Net+Android+IO开发 . .Net培训 .期待与您交流! JavaBean  内省 软件包 java.beans 包含与开 ...

  2. java beans

    There are N little kids sitting in a circle, each of them are carrying some java beans in their hand ...

  3. [ACM_水题] ZOJ 3714 [Java Beans 环中连续m个数最大值]

    There are N little kids sitting in a circle, each of them are carrying some java beans in their hand ...

  4. java.lang.ClassCastException: sun.jdbc.odbc.JdbcOdbcStatement cannot be cast to java.beans.Statement

    当导入的包为:import java.sql.Statement;时,无任何错误 当导入的包为:import java.beans.Statement;时,出错

  5. Java基础知识强化99:Java 常见异常及趣味解释

    常见 Java 异常解释:(译者注:非技术角度分析.阅读有风险,理解需谨慎:) 1. java.langjava.lang软件包是java语言的核心部分,它提供了java中的基础类. java.lan ...

  6. 深入理解Java类加载器(1):Java类加载原理解析

    1 基本信息 每个开发人员对Java.lang.ClassNotFoundExcetpion这个异常肯定都不陌生,这背后就涉及到了java技术体系中的类加载.Java的类加载机制是技术体系中比较核心的 ...

  7. SQLException: com.mchange.v2.c3p0.ComboPooledDataSource [ java.beans.IntrospectionException: java.lang.reflect.InvocationTargetException [numThreadsAwaitingCheckoutDefaultUser] ] has been closed()

    问题:Could not get JDBC Connection; nested exception is java.sql.SQLException: com.mchange.v2.c3p0.Com ...

  8. Spring3.2 Contorller单元测试参数问题: java.lang.NoSuchMethodException

    使用3.2做单元测试的时候发现这个问题,因为之前都是用3.0中的配置适配器使用AnnotationMethodHandlerAdapter,到3.2中升级为RequestMappingHandlerA ...

  9. 沉淀,再出发:Java基础知识汇总

    沉淀,再出发:Java基础知识汇总 一.前言 不管走得多远,基础知识是最重要的,这些知识就是建造一座座高楼大厦的基石和钢筋水泥.对于Java这门包含了编程方方面面的语言,有着太多的基础知识了,从最初的 ...

随机推荐

  1. Visual Studio Community 2013 中文语言包-离线安装版

    vs_langpack.exe /layout 命令运行或者批处理运行. 转自:http://www.tuicool.com/articles/uMzqAnA 现成安装包下载地址:链接: http:/ ...

  2. C BIN加密

    #include <stdio.h> #include <string.h> #include <stdlib.h> #ifndef DWORD #define D ...

  3. 配置 host only 后 nat不能上网了

    如果只有nat 网关为nat 中设置的网关  eth0 启动第二块网卡host_only 网关就变成了 host_only中的网关  eth1 解决放法 route -n 看启用的是哪个网关 [roo ...

  4. 智能家居入门DIY——【三、GP2Y10之颗粒物传感器】

    这个传感器接线算比较简单的,程序也不麻烦.不过这东西是颗粒物传感器吧,不是神马PM2.5(总悬浮颗粒物),不是神马PM10(可吸入颗粒物).插个螺丝刀进去度数也是变的,不是说的很清楚原理是反光嘛……… ...

  5. css用法大全

    direction:控制文本方向 ltr:默认.文本方向从左到右. rtl:文本方向从右到左. inherit:规定应该从父元素继承 direction 属性的值. <select name=& ...

  6. 无法正确解析FreeMarker视图

    在使用SpringMVC处理FreeMarker的时候,出现了无法解析视图名的问题,报的异常说明的也非常清楚就是不能解析视图 这个free就是一个FreeMarker的模板名,它的完整路径是/WEB- ...

  7. python Flask篇(一)

    MarkdownPad Document *:first-child { margin-top: 0 !important; } body>*:last-child { margin-botto ...

  8. 20165233 实验一 Java开发环境的熟悉

    20165233 实验一 Java开发环境的熟悉 实验要求 1.没有Linux基础的同学建议先学习<Linux基础入门(新版)><Vim编辑器> 课程: 2.完成实验.撰写实验 ...

  9. 关于C语言中%p和%X的思考

    说白了,(%A)仅仅代表以何种格式显示所要显示的数据,具体何种格式如下: %d 有符号10进制整数 %i 有符号10进制整数 %o 无符号8进制整数 %u 无符号10进制整数 %x 无符号的16进制数 ...

  10. numpy中的ndarray方法和属性

    原文地址 NumPy数组的维数称为秩(rank),一维数组的秩为1,二维数组的秩为2,以此类推.在NumPy中,每一个线性的数组称为是一个轴(axes),秩其实是描述轴的数量.比如说,二维数组相当于是 ...