QOJ.ac

QOJ

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

#572. 积木

الإحصائيات

Bytie 在生日时收到了一套木块。这些木块彼此无法区分,因为它们都是大小相同的立方体。Bytie 通过将一个木块叠在另一个木块上来堆叠木块。很快,他就有了一排这样的堆,一个接一个地排成一条直线。当然,这些堆的高度可以不同。

Bytie 的父亲 Byteasar 给儿子出了一个谜题。他给出了一个数字 $k$,并要求 Bytie 重新排列这些木块,使得高度至少为 $k$ 的连续堆的数量最大化。然而,Bytie 只允许从高度严格大于 $k$ 的堆顶取走一个木块,并将其放置在相邻的堆顶上。此外,Bytie 不允许创建新的堆,他只能在现有的堆之间移动木块。

标准输入的第一行包含两个由空格分隔的整数:$n$ ($1 \le n \le 1\,000\,000$),表示堆的数量;$m$ ($1 \le m \le 50$),表示 Byteasar 的询问次数。堆的编号从 $1$ 到 $n$。第二行包含 $n$ 个由空格分隔的整数 $x_1, x_2, \dots, x_n$ ($1 \le x_i \le 1\,000\,000\,000$)。数字 $x_i$ 表示第 $i$ 个堆的高度。第三行包含 $m$ 个由空格分隔的整数 $k_1, k_2, \dots, k_m$ ($1 \le k_i \le 1\,000\,000\,000$)。这些是需要解决谜题的后续参数 $k$ 的值。也就是说,对于每个给定的参数 $k$,需要确定通过允许的移动所能获得的高度至少为 $k$ 的连续堆的最大数量。

程序应向标准输出打印 $m$ 个由空格分隔的整数,其中第 $i$ 个整数应为针对给定的初始堆设置和参数 $k_i$ 的谜题答案。

样例

输入格式 1

5 6
1 2 1 1 5
1 2 3 4 5 6

输出格式 1

5 5 2 1 1 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.