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. 设置JAVA HOME环境变量的秕处理

    echo "放在JDK目录下,win xp需要下载SETX.EXE" setx /m Java_Home "%cd%" setx /m ClassPath &q ...

  2. php变量的实现

    1.php变量的实现 变量名 zval ,变量值 zend_value,php7的变量内存管理的引用计数 在zend_value结构上,变量的操作也都是zend_value实现的. //zend_ty ...

  3. python 下载图片的方法

    a='http://wx1.sinaimg.cn/mw600/006HOayNgy1fqjdi2nxohj32pw3o8x6s.jpg'  #图片下载地址   ( 这里改成 文件txt地址)w='/U ...

  4. python的with用法

    转自http://blog.kissdata.com/2014/05/23/python-with.html With语句是什么? 有一些任务,可能事先需要设置,事后做清理工作.对于这种场景,Pyth ...

  5. 如何制作简单的 3D 打印模型

    Hi 大家好! 了解一个方兴未艾,但极为有趣的话题 — 3D 打印 . 为了帮助大家对3D打印有一个初步的感性认识,我在线制作了一款可用于3D打印的model, 大家可以先通过体验这个在线 model ...

  6. ubantu的安装和卸载

    ubuntu软件安装与卸载 更新Ubuntu软件下载地址 1. 寻找国内镜像源 所谓的镜像源:可以理解为提供下载软件的地方,比如Android手机上可以下载软件的91手机助手:iOS手机上可以下载软件 ...

  7. 设置myeclipse文件的打开格式

  8. ICaptureGraphBuilder2::RenderStream 智能连接方法浅析

    ICaptureGraphBuilder2::RenderStream HRESULT RenderStream( [in] const GUID *pCategory, [in] const GUI ...

  9. JDK动态代理代码示例

    JDK动态代理代码示例 业务接口 实现了业务接口的业务类 实现了InvocationHandler接口的handler代理类 1.业务接口 package com.wzq.demo01; /** * ...

  10. ORA-10873

    [问题现象] SQL> ALTER DATABASE OPEN; alter database open * ERROR at line 1: ORA-10873: file 36 needs ...