QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 32 MB Total points: 100

#12697. 权重

Statistics

Byteotian 实验物理研究所搬迁至新址时遇到了一个物流问题——其庞大的精密砝码收藏品的转移工作变得十分棘手。

研究所拥有一定数量的容器,每个容器都有一定的承重上限。目标是将尽可能多的砝码放入容器中,无法放入的砝码将被丢弃。除了不能超过容器的承重上限外,对每个容器内放入的砝码数量没有限制。容器也可以保持为空。

研究所里的任意两个砝码都具有一个特殊的性质:其中一个砝码的质量是另一个砝码质量的整数倍。特别地,它们的质量可能相等。

请编写一个程序:

  • 从标准输入读取容器的承重上限和砝码的质量;
  • 确定可以放入容器中的砝码的最大数量;
  • 将结果输出到标准输出。

标准输入的第一行包含两个整数 $n$ 和 $m$ ($1 \le n, m \le 100\,000$),用空格分隔,分别表示容器的数量和砝码的数量。第二行包含 $n$ 个整数 $w_i$ ($1 \le w_i \le 100\,000\,000$,对于 $1 \le i \le n$),用空格分隔,表示容器的承重上限(单位:毫克)。第三行包含 $m$ 个整数 $m_j$ ($1 \le m_j \le 1\,000\,000\,000$,对于 $1 \le j \le m$),用空格分隔,表示砝码的质量(单位:毫克)。

标准输出的第一行应包含一个整数,即在不超过容器承重上限的前提下,可以放入容器中的砝码的最大数量。

样例

输入格式 1

2 4
13 9
4 12 2 4

输出格式 1

3

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.