编程介的小学生 2017-12-06 15:40 采纳率: 20.5%
浏览 957
已采纳

Little Sheep

Problem Description
As we all know, sheep are very lazy, they don’t like move and just want to enjoy delicious food. So, Mr. LittleSheep who is in charge of a farm which owns lots of sheep is extremely tired in feeding these sheep. Mr. LittleSheep’s farm is like a circle consists of n corrals, each corral has a certain number of sheep, and every corral has a door for feeding. When it comes to feeding time, Mr. LittleSheep has to decide in which orders should he open those doors, because he can just open one door every time, otherwise these tricky sheep would run away. When the door is opened, the lazy sheep whose distance to the open door less or equal to k will go out, the distance to the open door is defined by the number of corrals between the open door and sheep’s corral. Due to the narrow door, it is allowed just one sheep to leave per minute. In order to let other lazy sheep get fed, Mr. LittleSheep has to move to anther corral to open the door, we assume the distance between the current corral and the destination is D, and the maximum amount of sheep among the rest corrals is M, then it takes D*M minute to move. (Because every step Mr. LittleSheep moves, it takes M minute to calm down the largest group of sheep), Now the question is how Mr. LittleSheep should move to use the least time for feeding all these lazy sheep. Mr. LittleSheep always started his work at 1st corral.

Input
The first line is two integers n, k which indicates the number of corrals and the longest distance which sheep are willing to go.
The second line is n positive integers which describe the amount of sheep in each corral. The ith number a[i] is the number of sheep in ith corral.
(1 <= a[i] <= 10000)(1 <= n <= 2000, 1 <= k <= 500 ,k <= n/2 )

Output
The minimum minutes Mr. LittleSheep should take to feed all sheep.

Sample Input
6 1
4 1 2 3 1 3

Sample Output
21

  • 写回答

1条回答 默认 最新

  • threenewbee 2018-01-28 14:13
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?