A797.Berry Picking--Silver
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:128MB
题目描述
Bessie and her little sister Elsie are picking berries in Farmer John's berry patch. The patch has N berry trees, and tree i contains Bi berries.
Bessie has K baskets. Each basket can hold berries from only one tree, and a basket may be left empty. Bessie may divide the berries from one tree among multiple baskets.
Bessie wants to collect as many berries as possible. However, she must give Elsie the K/2 baskets containing the most berries. Determine the maximum number of berries Bessie can keep.
输入格式
The first line contains two integers N and K.
The second line contains N integers B1,B2,…,BN.
输出格式
Output one integer: the maximum number of berries Bessie can keep.
输入输出样例
输入#1
5 4 3 6 8 4 2
输出#1
8
说明/提示
For example, Bessie could fill one basket with 6 berries from tree 2, two baskets with 4 berries each from tree 3, and one basket with 4 berries from tree 4. Elsie takes the two baskets with 6 and 4 berries, so Bessie keeps 8 berries.
数据范围:
总体范围:1≤N≤1000,K 为不超过 1000 的正偶数,1≤Bi≤1000。
| 测试点 | 数据范围 |
|---|---|
| 01–04 | K≤10 |
| 05–11 | 无额外限制 |
输入解题思路,AI测评打分。不知道怎么写?