Problem A: Little Red Riding Hood

Time Limit: 1 Sec  Memory Limit: 1280 MB
Submit: 860  Solved: 133
[Submit][Status][Web Board]

Description

Once upon a time, there was a little girl. Her name was Little Red Riding Hood. One day, her grandma was ill. Little Red Riding Hood went to visit her. On the way, she met a big wolf. “That's a good idea.”,the big wolf thought. And he said to the Little Red Riding Hood, “Little Red Riding Hood, the flowers are so beautiful. Why not pick some to your grandma?” “Why didn't I think of that? Thank you.” Little Red Riding Hood said.
Then Little Red Riding Hood went to the grove to pick flowers. There were n flowers, each flower had a beauty degree a[i]. These flowers arrayed one by one in a row. The magic was that after Little Red Riding Hood pick a flower, the flowers which were exactly or less than d distances to it are quickly wither and fall, in other words, the beauty degrees of those flowers changed to zero. Little Red Riding Hood was very smart, and soon she took the most beautiful flowers to her grandma’s house, although she didn’t know the big wolf was waiting for her. Do you know the sum of beauty degrees of those flowers which Little Red Riding Hood pick? 

Input

The first line input a positive integer T (1≤T≤100), indicates the number of test cases. Next, each test case occupies two lines. The first line of them input two positive integer n and

k (

Output

Each group of outputs occupies one line and there are one number indicates the sum of the largest beauty degrees of flowers Little Red Riding Hood can pick.

Sample Input

1
3 1
2 1 3

Sample Output

5

HINT

 #include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; int a[], dp[]; int main()
{
int T, n, k;
scanf("%d", &T);
while(T--)
{
scanf("%d%d", &n, &k);
for(int i = ; i < n; i++){
scanf("%d", &a[i]);
dp[i] = a[i];
}
int mx = dp[];
int ans = ;
for(int i = k+; i < n; i++)
{
mx = max(mx, dp[i-k-]);
dp[i] = a[i] + mx;
if(ans < dp[i])ans = dp[i];
}
printf("%d\n", ans);
} return ;
}

华中农业大学第五届程序设计大赛网络同步赛-A的更多相关文章

  1. 华中农业大学第五届程序设计大赛网络同步赛-L

    L.Happiness Chicken brother is very happy today, because he attained N pieces of biscuits whose tast ...

  2. 华中农业大学第五届程序设计大赛网络同步赛-K

    K.Deadline There are N bugs to be repaired and some engineers whose abilities are roughly equal. And ...

  3. 华中农业大学第五届程序设计大赛网络同步赛-G

    G. Sequence Number In Linear algebra, we have learned the definition of inversion number: Assuming A ...

  4. 华中农业大学第五届程序设计大赛网络同步赛-D

    Problem D: GCD Time Limit: 1 Sec  Memory Limit: 1280 MBSubmit: 179  Solved: 25[Submit][Status][Web B ...

  5. [HZAU]华中农业大学第四届程序设计大赛网络同步赛

    听说是邀请赛啊,大概做了做…中午出去吃了个饭回来过掉的I.然后去做作业了…… #include <algorithm> #include <iostream> #include ...

  6. (hzau)华中农业大学第四届程序设计大赛网络同步赛 G: Array C

    题目链接:http://acm.hzau.edu.cn/problem.php?id=18 题意是给你两个长度为n的数组,a数组相当于1到n的物品的数量,b数组相当于物品价值,而真正的价值表示是b[i ...

  7. 华中农业大学第四届程序设计大赛网络同步赛 G.Array C 线段树或者优先队列

    Problem G: Array C Time Limit: 1 Sec  Memory Limit: 128 MB Description Giving two integers  and  and ...

  8. 华中农业大学第四届程序设计大赛网络同步赛 J

    Problem J: Arithmetic Sequence Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 1766  Solved: 299[Subm ...

  9. 华中农业大学第四届程序设计大赛网络同步赛 I

    Problem I: Catching Dogs Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 1130  Solved: 292[Submit][St ...

随机推荐

  1. 【五校联考3day2】C

    題意: 現有一平面直角坐標系,有n個點,每一個點必須向某一個方向發射射線,且任意一條射線必須與某一條坐標軸平行.定義一種發射射線的方案是合法的,則方案必須滿足: 1.沒有一條射線交叉 2.沒有一條射線 ...

  2. cad 关键字被保留了?选择集关键字保留了? N S W E关键字无法用?

    N S W E是东南西北四个方位,s是南方270度,在设置关键字的时候必须避开这四个关键字. 设置早期的R14 也有.

  3. javaweb项目中的过滤器的使用

    翻阅博客园的的时候,看到两篇关于javaweb过滤器的帖子写的很好,这里备忘一下: 过滤器基础:http://www.cnblogs.com/xdp-gacl/p/3948353.html 获取器案例 ...

  4. OSX10.12搭建IPv6本地环境测试APP

    前记 最近刚换了工作,生活终于又安定下来了,又可以更博了 正文 最近公司在上线APP(整体全是用JS去写的,就用了我原生的一个控制器),然后APP就去上线,就被苹果巴巴给拒了.通过阅读苹果回复的邮件, ...

  5. Shell - 简明Shell入门07 - 数组(Array)

    示例脚本及注释 #!/bin/bash test0=() # 定义数组 test1=(a b c d e f) # 定义数组 test2=( # 定义数组 'A?' "BB!" C ...

  6. markdown的学习记录

    一.markdown用处: 写博客,写微信公众号等等 二.准备工作: 工具使用:由于代码经常使用idea,所以继续使用idea编写markdown,但需要安装插件:MarkDown Navigator ...

  7. windows下docker的安装及常用命令学习

    docker search 镜像名 本文主要介绍Docker在Windows下的安装.关于Docker的介绍和文档在其官网中可以找到:http://www.docker.com .安装环境:Windo ...

  8. 插入排序(java)

    这星期java老师布置的作业就是实现几种常见的排序算法,由于数据结构学了丢得差不多了,今天晚上搞了一晚上才搞出来插入排序的三种算法. 首先说个与题目不搭的话,今天写

  9. SQL SERVICE中的锁

    SQL SERVICE中的几个锁 SELECT * FROM dbo.TableName WITH (NOLOCK) --不加任何锁的读,脏读SELECT * FROM dbo.TableName W ...

  10. JavaScript -- Window-框架

    -----025-Window-框架.html----- <!DOCTYPE html> <html> <head> <meta http-equiv=&qu ...