迷幻原题来了,大家欣赏一下。
所在版块:心情闲聊 发贴时间:2019-05-23 15:27

用户信息
复制本帖HTML代码
高亮: 今天贴 X 昨天贴 X 前天贴 X 
Barr the bear, Kang the Penquin, and Khang the car have just came back from another year of the internationally renowned programming competition, "I own iPads" (IOI), and have, as expected, come back with a shipment of N boxes of iPads, with the i-th box containing B_i iPads. Disembarking from the heavily laden cargo ship, the trio pounce/fly/jump from the ship onto solid ground, and make their way to a little-known resort, Tree Ville.

Despite Tree Ville being located in a desolate area far above the chimney tops, the perpetuators of evil, the Squidzofrenzic Calamari, an evil gang consisting of M squid, has found them!

After 23 hours of effort, the Squidzofrenzic Calamari finally managed to clip Kang's wings, force feed Khang with basic knowledge, and put Barr behind bars!

However, the Squidzofrenzic Calamari have agreed to let the IOI trio go, on one condition, that they sort out the mess of how to split the caches of iPads.

Being a very blur race, the Squidzofrenzic Calamari commander has demanded that the trio come up with a way to split the boxes of iPads among the horde of cephalopods, subject to the following conditions:

(i) To ensure equality, we wish to minimise the maximum number of iPads which any squid receives.
(ii) The amount of iPads in each box is indivisible, as the Squidzofrenzic Calamari are not in possession of machines capable of resealing the boxes, and iPads don't quite survive ten-mile underwater journeys very well.
(iii) To prevent further confusion, the boxes each squid gets must be consecutive (e.g. squid 6 gets boxes 17-42, but not boxes 17, 18, 20 etc.)

"What's this messy lousy formulation of a question. Just use a range tree..." Barr the bear growled and went to hibernate.

"This problem... tsk! Such a Tree Ville problem!" Kang the penquin quipped, and went into hiding in a freezer, never to be seen for the rest of the day.

Khang vanished mysteriously in search of free food after mysteriously saying something about fiascos.

And so, the Squidzofrenzic Calamari have thus an unresolved problem, and have consulted YOU to solve it for them.

Input
The first line of the input will contain two integers N and M (1 ≤ N, M ≤ 100,000).

The next line of the input will contain N integers, with the i-th integer representing B_i (1 ≤ B_i ≤ 1,000).

Output
The output should contain only one integer, representing the maximum number of iPads which any single squid receives.

Sample Input
9 3
1 2 3 4 5 6 7 8 9

Sample Output
17

Explanation for Sample Output
Dividing the iPads as such: 1 2 3 4 5 / 6 7 / 8 9 would fulfill the stipulated conditions, as any other division would increase number of iPads which the "luckiest" squid received. In this case, that squid is the third squid, which receives 17 iPads.
.
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!

 相关帖子 我要回复↙ ↗回到正文
问码农们一个算法问题。 3idiots   (1030 bytes , 1473reads )
并不是很暴力,因为有重复子问题,是动态规划 id_rsa   (212 bytes , 30reads )
对的。 3idiots   (0 bytes , 15reads )
目测楼主可以考虑用空间来换取时间 功夫熊猫   (193 bytes , 16reads )
可能我描述有误,不是自然数列。 3idiots   (32 bytes , 19reads )
那玩脱了 功夫熊猫   (0 bytes , 14reads )
迷幻原题来了,大家欣赏一下。 3idiots   (2782 bytes , 19reads )
还是你们厉害,我的手艺不行了,惭愧。 3idiots   (0 bytes , 12reads )
一粘贴代码全部gg,上个图 id_rsa   (58 bytes , 35reads )
[ThumbsUp][ThumbsUp][ThumbsUp],就欣赏实干的! zhbhope   (0 bytes , 28reads )
这题就是递归搜索嘛 id_rsa   (777 bytes , 22reads )
这是 python 吧?不太会,但是也能看。 3idiots   (84 bytes , 17reads )
没什么时间,说下基本思路吧 heathcliff   (287 bytes , 20reads )
一句“之后所以的分发”,略去了C(m,n)的复杂度。 zhbhope   (28 bytes , 22reads )
你可以再仔细想想 heathcliff   (5 bytes , 19reads )
我能想到的binary search是 zhbhope   (372 bytes , 19reads )
多谢啦。这么说我就懂了。 3idiots   (73 bytes , 13reads )
两种解法 yueli   (126 bytes , 25reads )
说的真简介明了,solution space 二分法。就是!复杂度是n*log(数组的和) zhbhope   (0 bytes , 22reads )
没错,这题就是用binary search,dp也可以的。但time complexity是binary search好的 github   (0 bytes , 30reads )
这个题目没看懂 wineywei   (309 bytes , 24reads )
原题是个充满了各种诡异精灵名字的 problem solving 小故事。。。 3idiots   (184 bytes , 14reads )
好像不是最大两个 cy1024   (48 bytes , 16reads )
划分型动态规划 小p友   (11 bytes , 27reads )