A.  A sad story

链接:https://www.nowcoder.com/acm/contest/89/A

来源:牛客网

时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 262144K,其他语言524288K
64bit IO Format: %lld

题目描述

The Great Wall story of Meng Jiangnv’s Bitter Weeping happened during the Qin Dynasty (221BC- 206BC). Meng jiangnv was a beauty in the Qin Dynasty, and she lived happily with her husband. At that time, Emperor Qin Shihuang (the first emperor of Qin) announced to build the Great Wall. And the officials suddenly broke in their happy life and took Meng’s husband away to build the wall. Because of the missing for her husband, she decided to set off to look for her husband. After a long journey, finally she reached the foot of the Great Wall at the present Shanhaiguan Pass. Upon her arrival, a bad news came to her, however, her husband had already died of exhaustion and was buried into the Great Wall! Meng could not help crying. She sat on the ground and cried and cried. Suddenly with a tremendous noise, a 400 kilometer-long (248-mile-long) section of the wall collapsed over her bitter wail.
Today, Qin Shihuang gets N stones. The height of the ith stone is Ai. He will use all these stones to rebuild the Great Wall. In order to make the Great Wall more sturdy, the prime minister Li Si proposes a formula to calculate the “weakness” of the reconstructed Great Wall
         
The Bi is the height of the ith stone in the reconstructed Great Wall, and the K is provided by Li Si.
For example, Qin Shihuang gets 5 stones. The height of these stones are [5,3,2,4,1], and the K is 2. There are 120 different ways to rebuild the Great Wall. The following figures show the two solutions:

The weakness of left figure and right figure are 4 and 11, respectively.

Now, Li Si wants to know the minimum value of “weakness”. Li Si is too old to calculate the answer quickly, so he asks you for help.

输入描述:

The first line contains an integer T, where T is the number of test cases. T test cases follow. For each test case, the first line contains two integers N and K, where N is the number of stones and K is a variable which provided by Li Si.

The second line contains N integers A1, A2, ... , AN, where Ai is the height of the ith stone that QinShiHuang gets.

• 1 ≤ T ≤ 50.

• 1 ≤ N ≤ 103
• 1 ≤ K ≤ N. 
• 1≤ Ai ≤104.

输出描述:

For each test case, print one line containing “Case #x: y”, where x is the test case number (starting from 1) and y is the minimum value of “weakness”.

第十四届浙江财经大学程序设计竞赛重现赛 ——A相关推荐

  1. 第十四届浙江财经大学程序设计竞赛 A A Sad Story【贪心】

    链接:https://www.nowcoder.com/acm/contest/89/A 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言5242 ...

  2. 华为杯大学生计算机软件大赛,关于举办2018年西安电子科技大学程序设计网络赛暨第十六届“华为杯”大学生程序设计竞赛的通知...

    各学院: 程序设计是大学生运用计算机充分展示自己分析问题和解决问题能力的一个重要途径,对于培养大学生实践能力.团队意识.创新意识.顽强意志和综合素质具有显著作用和效果.为了推动这项创新性素质教育活动的 ...

  3. 第十七届中国计量大学程序设计竞赛 D Dessert Time

    第十七届中国计量大学程序设计竞赛 D Dessert Time 题目描述 The party began, the greasy uncle was playing cards, the fat ot ...

  4. 第十四届全国大学生智能车竞赛竞赛技术报告下载链接

    第十四届智能车竞赛技术报告下载链接 01 下载报告   今天上午,看到有同学询问关于十四届智能车竞赛技术报告下载的询问. 实际上,之前第十四届的技术报告在百度上有, 只是没有能够提供下载链接. 由于第 ...

  5. 第十五届全国大学生智能汽车竞赛中小学生赛题组获奖队伍信息

    第十五届全国大学生智能汽车竞赛 中小学生赛题组获奖信息 序号 学校 队伍 组别 奖项 姓名 类别 1 青岛创新学校 - 高中 一等奖 孙彬航 参赛学生 2 国科大(青岛)附属学校 - 高中 一等奖 侯 ...

  6. 第九届浙江财经大学信息学院大学生程序设计竞赛

    A:水水更健康 时间限制: 1 Sec   内存限制: 128 MB [ 提交][ 状态][ 讨论版] 题目描述 zhourist是zufeoj的Rank2.他决定向Rank1发起进攻号角.于是他要刷 ...

  7. 福州大学第十四届程序设计竞赛-重现赛(Record)

    Problem A Salty Fish Accept: 108    Submit: 400 Time Limit: 1000 mSec    Memory Limit : 32768 KB  Pr ...

  8. 牛客网 第十七届中国计量大学程序设计竞赛(同步赛)(重现赛)B题 Broken Pad 暴力+思维

    题意: 给你两个01串,经过两种操作,1.直接让第一串经过操作变成目标串:2.可以点击空白处,即0的地方,使得操作串全部清空为0串,再变为目标串:最终比较两种方式,哪种需更少步骤,输出每步点击的位置. ...

  9. 第十四届蓝桥杯Web应用开发—模拟赛3期--网页PPT--蓝桥校园一卡通--心愿便利贴

    文章目录 1:网页PPT (5分) ✔✔✔ 2:蓝桥校园一卡通 (10分)✔✔✔ 3:心愿便利贴 (15分) ✔✔✔ 1:网页PPT (5分) ✔✔✔ switchPage( ) switchPage ...

最新文章

  1. GDB 格式化结构体输出
  2. 如何使用python批量下载-用Python调用迅雷实现后台批量下载
  3. C语言求最大公约数3种方法
  4. Node.js 框架设计及企业 Node.js 基础建设相关讨论
  5. java url 授权,Spring MVC框架 - 基本认证之URL 授权认证
  6. UNICODE十六进制数组转成中英文
  7. JDK和CGLIB动态代理区别
  8. [导入]C++ OpenGL底层和C# GUI无缝联合!
  9. OFBiz + Opentaps 目录管理 四. 产品(四)礼券
  10. java 计算器 下载_那里可以下载到JAVA编的计算器程序??
  11. [转]人像识别是个伪命题
  12. Ragel State Machine Compiler 的速度测试
  13. arduino-解决舵机与直流电机冲突问题
  14. 大学模电实验合集丨实验二 单管共射放大电路的原理
  15. 无线路由器桥接——手机连不上网
  16. 在bug的边缘疯狂试探之mybatis
  17. 计算机主机箱工作电流,电脑使用常识
  18. 乐视超级电视刷鸿蒙,乐视超3X55刷精简+root系统记录
  19. python判断天数_Python计算两个日期相差天数的方法示例
  20. python葡萄酒数据集_Python 数据挖掘- Kaggle红酒品质数据

热门文章

  1. Linux系统安装与基本操作
  2. Ubuntu更换apt源之arm版
  3. hdu2232 机器人的舞蹈
  4. 手机五款黑科技式APP 不用不知道
  5. SpringBoot+Redis 实现搜索栏热搜
  6. 从零开始学Seata(Fescar)-部署运行官方DEMO
  7. 计算机数据库英语词汇,计算机英语词汇:数据库
  8. geoserver (三)发布多层级天地图、谷歌地图、高德地图等底图切片服务
  9. 星淘惠跨境:100%纯干货分享,五个要点教你打造亚马逊爆款
  10. 公告 | 联盟链FISCO BCOS v2.0.0-rc3 发布