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. 02 - Unit011:Spring AOP

    Spring AOP 面向切面(儿)编程(横切编程) Spring 核心功能之一 Spring 利用AspectJ 实现. 底层是利用 反射的动态代理机制实现的 其好处: 在不改变原有功能情况下, 为 ...

  2. FT5X06 如何应用在10寸电容屏

    硬件搭起来看现象,如下图: 红色区域是FT5406上报有效数据的范围(1280*600),以左上角为原点 ,X轴方向上报数据的最大值1280,Y轴方向上报的最大数据是600..但是我用的LG的10.1 ...

  3. mediawikide

    wiki.conf server { listen 80; server_name wiki.talkvip.cn; index index.html index.htm index.php; roo ...

  4. 【转】Java中的内部类和匿名类

       Java内部类(Inner Class),类似的概念在C++里也有,那就是嵌套类(Nested Class),乍看上去内部类似乎有些多余,它的用处对于初学者来说可能并不是那么显著,但是随着对它的 ...

  5. arm-linux-gcc配置安装

    1.首先去下载arm-linux-gcc压缩包 https://pan.baidu.com/s/15QLL-mf0G5cEJbVP5OgZcA 密码:ygf3 2.把压缩包导入到Linux系统:htt ...

  6. Sql2008 全文索引 简明教程

    在SQL Server 中提供了一种名为全文索引的技术,可以大大提高从长字符串里搜索数 据的速度,不用在用LIKE这样低效率的模糊查询了.   下面简明的介绍如何使用Sql2008 全文索引 一.检查 ...

  7. Sql语句在线转java bean https://www.bejson.com/othertools/sql2pojo/

    https://www.bejson.com/othertools/sql2pojo/

  8. 13 MySQL--存储过程

    1.存储过程的介绍 对于存储过程,可以接收参数,其参数有三类: in 仅用于传入参数用 out 仅用于返回值用 inout 既可以传入又可以当作返回值 存储过程包含了一系列可执行的sql语句,存储过程 ...

  9. git_基本使用

    1.默认你已经安装了,git的客户端,这里我们使用git bash操作. 2.执行git init命令:     git ini 3.在本地创建ssh key: ssh-keygen -t rsa - ...

  10. python's decorator&wrapper

    [python's decorator&wrapper] decorator A function returning another function, usually applied as ...