QOJ.ac

QOJ

実行時間制限: 2 s メモリ制限: 1024 MB 満点: 100 難易度: [表示]

#2544. 平地货币

統計

Flatland 的货币系统使用面值为 500、100、50、10、5 和 1 的 Flatland 日元硬币。

在 Flatland 机场的商店里,有 $N$ 瓶 milkohol 出售;第 $i$ 瓶的价格为 $a_i$ 日元。注意这里总共有 $N$ 瓶酒,因此每瓶酒你最多只能购买一次。

你拥有 $X$ Flatland 日元,并且你注意到你所持有的硬币数量是在所有 $X$ 的表示方式中尽可能最少的。

在商店里,你可以进行任意多次以下操作序列:

  • 选择一些瓶子。
  • 为你选择的瓶子支付你所持有的一些硬币。
  • 商店使用最少数量的硬币找零(如果需要)。你可以假设商店永远不会缺少任何面值的硬币。

你承诺给你的朋友们带 1 日元硬币作为纪念品。请找出你在商店中能够收集到的 1 日元硬币的最大数量。

输入格式

第一行包含两个整数 $N$ 和 $X$ ($1 \le N \le 10^5$, $1 \le X \le 10^{14}$),分别表示商店中瓶子的数量和你拥有的 Flatland 日元金额。第二行包含 $N$ 个整数 $A_1, A_2, \dots, A_N$ ($1 \le A_i \le 10^9$),表示商店中瓶子的价格。

输出格式

输出一个整数:在访问商店后,你可能拥有的 1 日元硬币的最大数量。

样例

样例输入 1

5 57
9 14 31 18 27

样例输出 1

8

样例输入 2

4 50
11 11 11 11

样例输出 2

12

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.