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. CentOS 设置 oracle 开机自动启动

    CentOS 设置 oracle 开机自动启动 1. [root@localhost ~]# gedit /etc/oratab 文件内容为: # # This file is used by ORA ...

  2. nodeJs实现微信小程序的图片上传

    今天我来介绍一下nodejs如何实现保存微信小程序传过来的图片及其返回 首先wx.uploadFile绝大部分时候是配合wx.chooseImage一起出现的,毕竟选择好了图片,再统一上传是实现用户图 ...

  3. (原创)Callable、FutureTask中阻塞超时返回的坑点

    直接上代码 import java.util.concurrent.Callable; public class MyCallable implements Callable<String> ...

  4. StringBuffer、StringBuilder、冒泡与选择排序、二分查找、基本数据类型包装类_DAY13

    1:数组的高级操作(预习) (1)数组:存储同一种数据类型的多个元素的容器. (2)特点:每个元素都有从0开始的编号,方便我们获取.专业名称:索引. (3)数组操作: A:遍历 public stat ...

  5. (转)浅谈AIX下IPFilter防火墙

    1    序言 AIX操作系统发行至今,经历数个版本,功能不断增强,就安全方面IP Security也变化不少,如动作中增加了If等功能,但这次暂且讨论配置防火墙策略及防火墙的基本操作,其他高级功能待 ...

  6. configure: error: You need a C++ compiler for C++ support.[系统缺少c++环境]

    一.错误configure: error: You need a C++ compiler for C++ support.二.安装c++ compiler情况1.当您的服务器能链接网络时候[联网安装 ...

  7. JMP地址公式推导

    以上有个问题:为什么同样的汇编指令JMP 12345678却对应不同的机器码呢? 首先,机器码E9表明这是一个近跳转(Near Jmp) 这里需要补充下相关知识: JMP分3种: ①短跳转(Short ...

  8. Vue图片懒加载插件 - vue lazyload的简单使用

    Vue module for lazyloading images in your applications. Some of goals of this project worth noting i ...

  9. JavaScript -- Location

    -----043-Location.html----- <!DOCTYPE html> <html> <head> <meta http-equiv=&quo ...

  10. windows下通过VNC图形化访问Ubuntu桌面环境

    要在windows下图形化访问Ubuntu或其它Linux系统桌面环境有很多方法,我比较喜欢的是使用VNC服务,需要在Ubuntu下安装vncserver和在windows下安装客户端访问工具. 1. ...