QOJ.ac

QOJ

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

#5816. 主题公园

Estadísticas

过山车真是太好玩了!似乎每个去主题公园的人都想坐过山车。有些人独自前往;另一些人则结伴而行,除非整个团队能一起坐,否则他们不会上过山车。而且,每一个坐过过山车的人都想再坐一次。每人每次乘坐的费用是 1 欧元;你的任务是计算过山车今天总共能赚多少钱。

过山车一次最多可以容纳 $k$ 个人。人们以团队为单位排队。团队依次登上过山车,直到没有剩余团队或者下一个团队无法坐下为止;然后过山车出发,无论它是否坐满。一旦乘坐结束,所有的乘客会按原来的顺序重新排到队尾。过山车一天内会运行 $R$ 次。

例如,假设 $R=4$,$k=6$,有四个团队,人数分别为:1, 4, 2, 1。第一次过山车出发时,前两个团队 [1, 4] 会上车,剩下一个空位(人数为 2 的团队坐不下,而人数为 1 的团队不能插队到他们前面)。然后他们会排到队尾,此时队列变为 2, 1, 1, 4。第二次,过山车将容纳 4 个人:[2, 1, 1]。此时队列变为 4, 2, 1, 1。第三次,它将容纳 6 个人:[4, 2]。此时队列变为 [1, 1, 4, 2]。最后,它将容纳 6 个人:[1, 1, 4]。过山车总共赚了 21 欧元!

输入格式

输入的第一行包含测试用例的数量 $T$。接下来是 $T$ 个测试用例,每个测试用例包含两行。第一行包含三个空格分隔的整数:$R$,$k$ 和 $N$。第二行包含 $N$ 个空格分隔的整数 $g_i$,每一个代表想要乘坐的团队人数。$g_0$ 是第一个团队的人数,$g_1$ 是第二个团队的人数,依此类推。

输出格式

对于每个测试用例,输出一行 "Case #x: y",其中 $x$ 是用例编号(从 1 开始),$y$ 是过山车赚取的欧元总数。

样例

输入格式 1

3
4 6 4
1 4 2 1
100 10 1
1
5 5 10
2 4 2 3 4 2 1 2 1 3

输出格式 1

Case #1: 21
Case #2: 100
Case #3: 20

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.