QOJ.ac

QOJ

时间限制: 5 s 内存限制: 1024 MB 总分: 100

#3186. 分币储蓄

统计

举办像 NWERC 这样的区域性竞赛需要大量的准备工作:组织房间和计算机、出题、邀请参赛选手、设计 T 恤、预订酒店房间等等。我负责去超市采购。

当我到达收银台时,我把所有的 $n$ 件商品放在传送带上,等待排在我前面的所有其他顾客结账。在等待时,我意识到这家超市最近开始将购买商品的总价四舍五入到最接近的 10 美分的倍数(5 美分向上取整)。例如,94 美分会被四舍五入到 90 美分,而 95 美分会被四舍五入到 100 美分。

我可以将我的购买商品分成若干组,并分别支付每一组的费用。我设法找到了 $d$ 个隔板,可以将我的商品分成最多 $d+1$ 组。我想知道应该把隔板放在哪里,以使我购买商品的总成本最小化。由于时间紧迫,我不想重新排列传送带上的商品。

图片由 Tijmen Stam 通过 Wikimedia Commons 提供,采用 cc by-sa 协议

输入格式

输入包含: 一行,包含两个整数 $n$ ($1 \le n \le 2\,000$) 和 $d$ ($1 \le d \le 20$),分别表示商品数量和可用的隔板数量; 一行,包含 $n$ 个整数 $p_1, \dots, p_n$ ($1 \le p_i \le 10\,000$,$1 \le i \le n$),表示商品的价格(单位为美分)。价格按照商品在传送带上出现的顺序给出。

输出格式

输出使用最多 $d$ 个隔板购买所有商品所需的最少金额。

样例

样例输入 1

5 1
13 21 55 60 42

样例输出 1

190

样例输入 2

5 2
1 1 1 1 1

样例输出 2

0

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.