QOJ.ac

QOJ

Límite de tiempo: 5 s Límite de memoria: 1024 MB Puntuación total: 10

#5897. 完美游戏

Estadísticas

你在玩一款电子游戏,如果你能连续通关所有关卡且不死亡,就能获得一项成就。你可以按任意顺序游玩这些关卡,每次游玩一个关卡时,你要么通关,要么死亡。每个关卡都有一定的通关概率,并且需要花费一定的时间。你应该按什么顺序游玩这些关卡,才能使获得该成就的期望时间最短?假设通关一个关卡或在其中死亡所需的时间相同,并且一旦死亡,你将立即从你所选顺序的第一个关卡重新开始。

注意:如果你未能通关某个关卡,你本人并不会死亡——只有你在游戏中的角色会死亡。如果不是这样的话,恐怕没几个人会尝试去赢取这个成就。

输入格式

输入的第一行包含测试用例的数量 $T$。接下来是 $T$ 个测试用例,每个测试用例包含三行。第一行包含一个整数 $N$,表示关卡数量。第二行包含 $N$ 个空格分隔的整数 $L_i$。$L_i$ 表示关卡 $i$ 所需的秒数,该时间与你是否通关或死亡无关。第三行包含 $N$ 个空格分隔的整数 $P_i$。$P_i$ 表示你在尝试关卡 $i$ 时死亡的百分比概率。

输出格式

对于每个测试用例,输出一行,包含 "Case #x: ",其中 $x$ 是测试用例编号(从 1 开始),后跟 $N$ 个空格分隔的整数。列表中的第 $j$ 个整数应该是你为了使获得成就的期望时间最短而应该尝试的第 $j$ 个关卡的索引。

索引从 $0$ 到 $N-1$。如果存在多种顺序能得到相同的期望时间,则输出字典序最小的顺序。在两个顺序中,字典序较小者是指在第一个不同的位置上索引较小的那个;在多个顺序中,字典序最小者是指比其他所有顺序的字典序都小的那个。

数据范围

$1 \le T \le 100$。 $0 \le P_i < 100$。

子任务 1

$1 \le N \le 20$。 $L_i = 1$。

子任务 2

$1 \le N \le 1000$。 $1 \le L_i \le 100$。

样例

样例输入 1

3
4
1 1 1 1
50 0 20 20
3
100 10 1
0 50 0
3
100 80 50
40 20 80

样例输出 1

Case #1: 0 2 3 1
Case #2: 1 0 2
Case #3: 2 0 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.