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. 闲扯淡笔记 - Web的历史

    这里的Web指的是万维网,就是World Wide Web. 文档和静态资源 通过URL组织 Tim Berners Lee (TimBL) 于1989发明这个概念,这丫55年出生,和我父亲一般大. ...

  2. Java 简单TCP文件传输

    服务端 package TCP; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputSt ...

  3. LIS系列总结

    此篇博客总结常见的LIS模型变形的解法. ------------------------------------------------------------------- 〇.LIS的$O(Nl ...

  4. 新手之:SpringBoot ——Reids主从哨兵整合(CentOS7)

    一.Redis主从搭建(一台服务器模拟多个端口) 结构图:) 1.确保安装了Redis,我装在了/opt/redis目录下.可通过"whereis redis-cli"命令查看是否 ...

  5. selenium+python自动化83-pip安装selenium报Read time out HTTPSConnectionPool(host='pypi.python.org' port443)

    遇到问题 1.有些小伙伴在用pip安装selenium时候报 Read time out HTTPSConnectionPool(host='pypi.python.org' port443) 2.估 ...

  6. ArcGIS中各种合并要素(Union、Merge、Append、Dissolve)的异同点分析 转载

    标签: arcgis 杂谈 分类: GISArcGIS中将两个要素类合并成一个要素有Union.Dissolve.Append.Merge等,在Arctoolbox中均有相应工具,但功能上有所不同:U ...

  7. Redis 位操作

    [Redis 位操作] 1.GETBIT key offset 对 key 所储存的字符串值,获取指定偏移量上的位(bit). 当 offset 比字符串值的长度大,或者 key 不存在时,返回 0  ...

  8. JobTracker和TaskTracker

    [JobTracker和TaskTracker] 1.JobTracker  对应于 NameNode,TaskTracker 对应于 DataNode. 2.JobTracker是一个master服 ...

  9. cookie的长度和限制数量

    一.浏览器允许每个域名所包含的 cookie 数 Microsoft 指出 Internet Explorer 8 增加 cookie 限制为每个域名 50 个,但 IE7 似乎也允许每个域名 50 ...

  10. 使用Git将码云上的代码Clone至本地

    1. 安装Git https://git-scm.com/book/zh/v2/%E8%B5%B7%E6%AD%A5-%E5%AE%89%E8%A3%85-Git Git的网站上有详细的分各种系统的安 ...