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 ≤ MN). 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 题目大意:
有一些豆子排成一个圈,然后从这个圈里找m个豆子,求m个豆子最大的质量是多少
#include <stdio.h>
int main(){
int t;
int a[];
int n,m;
int i;
int sum,max;
scanf("%d",&t);
while(t--){
scanf("%d%d",&n,&m);
for(i=;i<n;i++)
scanf("%d",&a[i]);
sum=;max=;
for(i=;i<m;i++)
sum+=a[i];
max=sum;
for(i=;i<n;i++){
sum=sum-a[i]+a[(i+m)%n];
if(sum>max)
max=sum;
}
printf("%d\n",max);
}
}

java beans的更多相关文章

  1. [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 ...

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

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

  3. 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 ...

  4. ZOJ3714:Java Beans

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

  5. Freemaker的java.beans.IntrospectionException: type mismatch between read and write methods

    引言:freemaker在特定的spring以及jdk下的问题解决路径. 环境描述 spring 3.1.1, jdk1.8u80, freemake 2.3.19 错误信息描述: 严重: Excep ...

  6. java.beans.PropertyChangeListener

    import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.beans.P ...

  7. JSP中操作Java Beans

    以下内容引用自http://wiki.jikexueyuan.com/project/jsp/beans.html: JavaBean是在编写Java时专门创建的Java类,根据JavaBean AP ...

  8. Oracle EBS Form Builder使用Java beans创建窗体

    最近有个项目,需要研究一下Oracle的E-Business Sutie(EBS),对于以前没接触此套件的我来说,简直太痛苦了.在网上找了一堆资料,试着进行Form二次开发,也遇到各类奇葩问题.目前遇 ...

  9. 解决java.beans.Introspector导致的内存泄漏

    解决方案: 在WEB.XML 中配置监听器: <listener> <listener-class> org.springframework.web.util.Introspe ...

随机推荐

  1. tornadod的异步代码

    #!/usr/bin/env python # -*- coding: utf-8 -*- import tornado.httpserver import tornado.ioloop import ...

  2. 十一. 一步步破解JEB 2.0demo版一

    字符串解密算法还愿 jeb.jar为核心功能,所以主要分析这个 1. jar转dex在使用jeb分析 Android\sdk\build-tools\23.0.3 dx.bat --dex --out ...

  3. gbk和gb2312的区别

    //GB2312是中国规定的汉字编码,也可以说是简体中文的字符集编码;GBK 是 GB2312的扩展 ,除了兼容GB2312外,它还能显示繁体中文,还有日文的假名 //总体说来,GBK包括所有的汉字, ...

  4. 【目录】python

    python 入门学习(一) 入门学习(二) 入门学习(三) 入门学习(四) 入门学习(五) 入门学习(六) 入门学习(七) 入门学习(八) 入门学习(九) 入门学习(十) Head First Py ...

  5. 通过ios实现RSA加密和解密

    在加密和解密中,我们需要了解的知识有什么事openssl:RSA加密算法的基本原理:如何通过openssl生成最后我们需要的der和p12文件. 废话不多说,直接写步骤: 第一步:openssl来生成 ...

  6. angularjs之ng-if、ng-show、ng-switch那些事

    一.蓝瘦~香菇   经常在项目中使用ng-if和ng-show来处理一些简单的状态,今天碰到一个复杂的状态判断,不经让我想起ng-switch.第一次接触他的时候,我没怎么注意他,因为我直接把他当作其 ...

  7. 《DSP using MATLAB》示例Example5.16

    代码: x1 = [1,2,2,1]; x2 = [1,-1,-1,1]; x3 = conv(x1,x2); % N = 5 n1 = 0:1:length(x1)-1; n2 = 0:1:leng ...

  8. Daily Scrum Meeting ——FourthDay

    一.Daily Scrum Meeting照片 橙汁去北京参加 ICPC比赛了,差不多15号回来 二.Burndown Chart 终于不是一条直线了..

  9. curl 小结

    cURL可以使用URL的语法模拟浏览器来传输数据, 因为它是模拟浏览器,因此它同样支持多种协议,FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, FILE 以 ...

  10. Bugtags 测试平台(支持ios、android)

    官网:https://bugtags.com/ 注意:小米手机 授权 打开漂浮窗 App 集成 Bugtags SDK 后,测试人员就可直接在 App 里所见即所得的提交 Bug; SDK 会自动截屏 ...