A797.Berry Picking--Silver

普及/提高-

USACO

通过率:0%

时间限制:1.00s

内存限制:128MB

题目描述

Bessie and her little sister Elsie are picking berries in Farmer John's berry patch. The patch has NN berry trees, and tree ii contains BiB_i berries.

Bessie has KK 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/2K/2 baskets containing the most berries. Determine the maximum number of berries Bessie can keep.

输入格式

The first line contains two integers NN and KK.

The second line contains NN integers B1,B2,…,BNB_1,B_2,\ldots,B_N.

输出格式

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≤10001\le N\le 1000,KK 为不超过 10001000 的正偶数,1≤Bi≤10001\le B_i\le 1000。

测试点 数据范围
01–04 K≤10K\le 10
05–11 无额外限制

输入解题思路,AI测评打分。不知道怎么写?

首页