QOJ.ac

QOJ

حد الوقت: 7 s حد الذاكرة: 1024 MB مجموع النقاط: 100

#2403. 邮票组合

الإحصائيات

你正准备去商店取包裹、包装并邮寄。你想要带一定数量的邮票去邮寄包裹,而你手头有一长卷邮票可以使用。随着时间的推移,你偶尔会从卷中的某个地方撕下一枚邮票,现在你剩下的是一条邮票,邮票以组的形式聚集在一起,中间由空白处隔开。

出于实际考虑,你不想撕开单个邮票,因此你只会沿着邮票组之间的缝隙撕开。此外,你不想剩下多卷邮票,所以你只能从卷的开头或结尾撕下这些邮票组。你手头的这卷邮票能做到这一点吗?

Photo by John Keyser

输入格式

第一行包含两个整数 $m$ 和 $n$($1 \le m, n \le 10^6$,$1 \le m \cdot n \le 10^7$),分别表示邮票组的数量和询问的数量。

第二行包含 $m$ 个整数 $a_i$($1 \le a_i \le 100$),以空格分隔。这些数字按从卷的开头到结尾的顺序给出了每组邮票的数量。

接下来的 $n$ 行,每行包含一个整数 $q$($0 \le q \le 10^8$),表示一个询问,即邮寄包裹所需的邮票数量。

输出格式

对于每个询问,如果能够凑出该数量的邮票,则输出一行 "Yes",否则输出 "No"。

说明

该卷包含 5 组邮票。

  • 可以通过从卷上撕下第一组邮票来获得 2 枚邮票。
  • 可以通过从卷上撕下前两组邮票来获得 10 枚邮票。
  • 可以通过从卷上撕下第一组(2 枚)和最后一组(3 枚)来获得 5 枚邮票。
  • 可以通过取走整卷邮票来获得 17 枚邮票。
  • 无法只取 1 枚邮票,因为撕开卷去取中间的单枚邮票不会让你剩下完整的一卷,而且也不可能在邮票组的中间撕开。

样例

样例输入 1

5 5
2 8 1 3 3
2
10
5
17
1

样例输出 1

Yes
Yes
Yes
Yes
No

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.