#P1001. 更多牛铃(b)
更多牛铃(b)
Problem description
Kevin Sun wants to move his collection of cowbells from Naperthrill to Exeter, where there is more grass than corn. Before moving, he must pack the cowbell into boxes of a fixed size. To ensure transportation safety, each box can only contain a maximum of two cowbells. Since Kevin wants to reduce his expenses, he wants to know the smallest box size that can be used to fit all the cowbells into the box.
Kevin is a meticulous collector of cow bells. He knows that the size of the th () cow bell is an integer . In fact, he has already sorted the cow bells by size, so for , we have . At the same time, as a packaging expert, Kevin can put one or two cowbells into a box, provided that their total size does not exceed the size of the box . Based on this information, help Kevin find the smallest box size such that he can fit all the cowbells into boxes.
Input format
The first line of input contains two integers and () separated by a space, which represent the number of cow bells and the number of boxes, respectively.
The next line contains space-separated integers () denotes the size of Kevin's cow bell. Ensure that the size of the cowbells given is in non-decreasing order.
Output format
Output an integer representing the minimum box size such that all the cowbells can be packed into boxes.
2 1
2 5
7
4 3
2 3 5 9
9
3 2
3 5 7
8
Tips
In the first example, Kevin must pack two cowbells into the same box.
In the second example, Kevin can package the cowbell in the following ways: , (), and ().
In the third example, the optimal solution is to package the cow bell into () and ().
相关
在下列比赛中: