QOJ.ac

QOJ

Límite de tiempo: 4 s Límite de memoria: 1024 MB Puntuación total: 100

#3194. 背包收集

Estadísticas

Gerald 的工作是在林雪平机场迎接今年 NWERC 的参赛队伍。他的职责之一是站在行李传送带旁,收集各队带来的行李包。Gerald 很懒,所以他只是站在传送带的同一个位置,等待行李包经过,然后将其取下。

图片由 Bernhard J. Scheuvens 通过 Wikimedia Commons 提供。

行李传送带由 $s$ 个行李槽组成,编号从 $0$ 到 $s - 1$。由于行李传送带是循环的,行李槽 $s - 1$ 和 $0$ 也相邻。传送带的转动方式使得如果 Gerald 在某一时刻站在槽 $i$ 前,那么一个单位时间后他将站在槽 $(i + 1) \pmod s$ 前。

起初,Gerald 在某个位置准备好了一个巨大的行李车,并站在那里等待行李。当一个行李包到达 Gerald 面前时,他需要 $t$ 个单位时间将其取下并放到行李车上。在这 $t$ 个单位时间后,他就可以准备取下一个行李包了。只要行李传送带上还有剩余的行李包,Gerald 总会在处理完上一个行李包并准备好后,立即取走下一个到达他所在位置的行李包。

现在,Gerald 想知道他选择的位置对完成这项任务所需时间的影响。请你帮助 Gerald 计算在所有 $s$ 个可能的初始位置下,取完所有行李包所需时间的最小值、最大值和平均值。时间从他在传送带的某个槽位准备好行李车开始计算,到他将最后一个行李包放到车上结束。

输入格式

输入包含: 一行,包含三个整数 $n$ ($1 \le n \le 2\,000$),$s$ ($1 \le s \le 10^7$) 和 $t$ ($1 \le t \le 10^7$),其中 $n$ 是要取走的行李包数量,$s$ 是传送带的槽位数,$t$ 是 Gerald 从传送带上取下一个行李包并放到车上所需的时间单位数; 一行,包含 $n$ 个整数 $k_1, \dots, k_n$ ($0 \le k_i \le s - 1$,对于 $1 \le i \le n$),表示行李包所在的槽位。

同一个槽位上可能会堆叠多个行李包,但 Gerald 一次只能取走一个行李包。

输出格式

输出三行,分别包含在所有 $s$ 个位置下,取完所有行李包所需时间的最小值、最大值和平均值。平均值应以最简分数 $p/q$ 的形式输出。

样例

输入格式 1

7 10 10000000
0 0 0 0 0 0 1

输出格式 1

70000001
70000009
350000027/5

输入格式 2

10 10 3
0 0 2 2 4 4 6 6 8 8

输出格式 2

39
40
79/2

输入格式 3

9 10000000 1
0 7 2 3 4 5 6 1 8

输出格式 3

9
10000000
12500021249991/2500000

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.