QOJ.ac

QOJ

时间限制: 2.5 s 内存限制: 1024 MB 总分: 100

#6400. 游戏:蔚蓝

统计

Madeline 正在攀登 Celeste 山。当前路段包含 $n$ 个柱子,分别位于位置 $x_1, x_2, \dots, x_n$。相邻柱子之间没有地面,因此 Madeline 只能在柱子之间移动,不能停留在中间。第 $i$ 个柱子顶部有一个大小为 $a_i$ 的草莓。每当 Madeline 到达一个柱子时,她可以选择收集该柱子上的草莓。

Madeline 在第一个柱子上学会了“波冲”(wavedash)技巧,并希望在这一路段练习该技巧。然而,由于风力条件,Madeline 的波冲只能将她带到 $[x + L, x + R]$ 范围内的位置,其中 $x$ 是 Madeline 当前的位置。

到达第 $n$ 个柱子后,Madeline 将使用她收集到的草莓来评估她的技巧。在比较两组草莓序列时,她会将草莓按大小进行非递增排序,然后比较排序后草莓序列的字典序。如果字典序更大,她会感到更满意。

在付诸实践之前,Madeline 想要规划一条从第 $1$ 个柱子到第 $n$ 个柱子的路线,使她的满意度达到最大。请帮助 Madeline。

输入格式

输入包含多个测试用例。 第一行包含一个整数 $T$,表示测试用例的数量。 对于每个测试用例,第一行包含三个整数 $n, L, R$ ($1 \le n \le 10^6, 1 \le L \le R \le 10^9$),分别表示柱子的数量和波冲的参数。 第二行包含 $n$ 个整数,第 $i$ 个整数为 $x_i$ ($1 \le x_i \le 10^9$),表示第 $i$ 个柱子的位置。保证对于 $1 \le i < n$ 有 $x_i < x_{i+1}$。 第三行包含 $n$ 个整数,第 $i$ 个整数为 $a_i$ ($1 \le a_i \le n$),表示第 $i$ 个柱子上草莓的大小。 保证所有测试用例的 $n$ 之和不超过 $10^6$。

输出格式

对于每个测试用例,如果 Madeline 无法到达第 $n$ 个柱子,输出 $-1$。否则输出两行。 第一行包含一个整数 $k$,表示 Madeline 收集到的草莓数量。 第二行包含 $k$ 个整数,表示 Madeline 收集到的草莓大小,按非递增顺序排列。

样例

输入格式 1

2
5 2 3
1 2 3 4 5
5 2 3 1 4
3 1 2
1 4 7
3 3 3

输出格式 1

3
5 4 3
-1

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.