1199: Little Red Riding Hood

Time Limit: 1 Sec  Memory Limit: 1280 MB
Submit: 918  Solved: 158
[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 (2 <= n <= 10^5 ) ,1 <=  k <= n ), the second line of them input n positive integers a (1<=a <=10^5)

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

最新文章

  1. linux中vi编辑器的使用
  2. setTimeout()和setInterval() 何时被调用执行
  3. 原生JS实现苹果菜单
  4. Linux数组array基础
  5. sql 通过存储过程和自定义类型批量新增数据
  6. BIEE应用存储过程并从前台传参
  7. android开发过程中踩过的坑
  8. RGB和HSV颜色空间
  9. HDU 1754 I Hate It(线段树区间求最值)
  10. js获取文本的行数
  11. Uniprot数据库
  12. Linux下Oracle数据库的安装
  13. HAProxy基础
  14. byte ---&gt; hex String
  15. Eclipse调试多线程代码
  16. 【读书笔记】iOS-解析JSON
  17. python 全栈开发,Day45(html介绍和head标签,body标签中相关标签)
  18. 大型网站系统与Java中间件实践读书笔记
  19. Hbase之IP变更后无法启动问题解决
  20. Magical Girl Haze 南京网络赛2018

热门文章

  1. 如何对你的Python代码进行基准测试
  2. HTTP1.1中CHUNKED编码解析
  3. 【AWS】订阅AWS论坛的RSS消息获取最新公告
  4. 关于SIM800C MINI V4.0 V4版本 5v供电模块重启问题
  5. phonegap file api
  6. 爬虫二 requests模块的使用
  7. 算法题 19 二叉平衡树检查 牛客网 CC150
  8. MySQL数据库(7)_MySQL 数据备份与还原
  9. PAT 天梯赛 L1-024. 后天 【取余】
  10. hadoop05---进程线程