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. Servlet 之 HttpServlet

    package cn.jiemoxiaodi.http; import java.io.IOException; import javax.servlet.GenericServlet; import ...

  2. cf593d

    题意:给出一个有n(n<=200000)的树形图,每条边有一个权值.有两种操作,1是将一个边的权值变小, 2是给定两点a,b和一个值y,用y(long long范围内)依次除以两点之间的路径上的 ...

  3. ACM/ICPC 之 卡卡的矩阵旅行-最小费用最大流(可做模板)(POJ3422)

    将每个点拆分成原点A与伪点B,A->B有两条单向路(邻接表实现时需要建立一条反向的空边,并保证环路费用和为0),一条残留容量为1,费用为本身的负值(便于计算最短路),另一条残留容量+∞,费用为0 ...

  4. android 扫描

    http://blog.csdn.net/abidepan/article/details/11902041

  5. Ubuntu16.04安装nginx

    //ubuntu //安装nginxcurl -LJO http://nginx.org/download/nginx-1.10.1.tar.gz tar zxvf nginx-1.10.1.tar. ...

  6. Jprofile监控本地tomact

    第一步:安装Jprofile后,点击jprofiler.exe 第二步:配置要监控的tomact 1.点击startcenter 2.弹出对话框,点击new session下面的new server ...

  7. 利用python的双向队列(Deque)数据结构实现回文检测的算法

    #!/usr/bin/env python # -*- coding: utf-8 -*- # learn <<Problem Solving with Algorithms and Da ...

  8. Python学习笔记(五)——list和tuple

    一.list 1.定义: list是一种有序的集合,可以随时添加和删除其中的元素 2.声明方法: subjects=['Math','English', 'Chinese'] 3.一些api (1)获 ...

  9. java调用sqlldr导入csv文件数据到临时表

    package cn.com.file;import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.File; ...

  10. uva12546. LCM Pair Sum

    uva12546. LCM Pair Sum One of your friends desperately needs your help. He is working with a secret ...