QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 256 MB 満点: 100

#2054. 摩天大楼

統計

在城市 Yecho 的主干道上,有 $N$ 座摩天大楼依次排列。从左向右看,它们的高度序列为 $a_1, a_2, \dots, a_N$。

海怪 Ugurbato 入侵了这座城市。当 Ugurbato 击中一座摩天大楼时,该大楼会被摧毁;此外,Ugurbato 的力量非常强大,它会产生一股冲击波,向被击中大楼的左右两侧扩散。

考虑冲击波向左传播的部分。假设 Ugurbato 击中了第 $i$ 座摩天大楼。如果冲击波遇到已经摧毁的摩天大楼,它就会衰减。如果冲击波遇到尚未摧毁的第 $k$ 座摩天大楼,当且仅当 $a_i - a_k \ge |i - k|$ 时,该大楼会被摧毁,且无论该大楼是否被摧毁,冲击波都不会在此处衰减。向右传播的冲击波过程与之类似。

Ugurbato 总共进行 $M$ 次攻击,下一次攻击均在两次冲击波完全衰减后进行。

请输出每次 Ugurbato 攻击后被摧毁的摩天大楼总数。

输入格式

第一行包含一个整数 $N$ ($1 \le N \le 10^5$),表示摩天大楼的数量。

第二行包含 $N$ 个空格分隔的整数 $a_1, a_2, \dots, a_N$,表示从左到右摩天大楼的高度 ($1 \le a_i \le 10^9$)。

第三行包含一个整数 $M$ ($1 \le M \le N$),表示 Ugurbato 的攻击次数。

第四行包含 $M$ 个空格分隔且互不相同的整数 $b_1, b_2, \dots, b_M$,表示 Ugurbato 依次击中的摩天大楼编号(摩天大楼从左到右编号,从 1 开始)。保证对于任意 $i$,大楼 $b_i$ 在被 Ugurbato 直接击中之前,尚未被之前的冲击波摧毁。

输出格式

输出 $M$ 行,每行包含一个整数,表示第 $i$ 次攻击后被摧毁的摩天大楼总数。

样例

样例输入 1

5
3 2 4 10 5
2
3 4

样例输出 1

2
2

样例输入 2

5
1 2 3 2 1
1
3

样例输出 2

5

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.