QOJ.ac

QOJ

Límite de tiempo: 1.0 s Límite de memoria: 256 MB Puntuación total: 100

#13188. 会议

Estadísticas

你是 X 公司的老板,有 $N$ 名下属。今天,第 $i$ 名下属会在你到达办公室 $A_i$ 秒后到达。

你今天将举行一次团队会议。由于会议室容量有限,必须恰好有 $K$ 名下属(不包括你)参加团队会议。你可以在你到达办公室 $S$ 秒后开始会议。你可以自由选择 $S$ 的值,但它必须是一个正实数且不能是整数。所有在会议开始时已经到达办公室的人都会参加会议。

你可以调整下属的到达时间。每支付 $1$ 美元,你可以选择一名下属,将其到达时间提前一秒或推迟一秒。然而,下属到达办公室的时间不能早于你(即不能小于 $0$),否则对你来说会很丢脸。此外,下属到达办公室的时间不能晚于你到达后 $T$ 秒,否则该下属可能会被解雇。你可以调整任意多名下属的到达时间,也可以多次调整同一名下属的到达时间。

请确定为了让恰好 $K$ 名下属(不包括你)参加会议,所需支付的最少美元金额。如果无法做到,输出 -1。

输入格式

第一行包含三个整数:$N, K, T$ ($1 \le K \le N \le 100,000$; $0 \le T \le 1,000,000,000$),分别表示下属总数、参加会议的下属人数以及最大允许到达时间。 第二行包含 $N$ 个整数:$A_1, A_2, \dots, A_N$ ($0 \le A_i \le T$),表示每名下属的到达时间。

输出格式

输出一行,表示为了让恰好 $K$ 名下属(不包括你)参加会议所需支付的最少美元金额。如果无法做到,输出 -1。

样例

样例输入 1

4 2 4 
1 2 3 4

样例输出 1

0

样例输入 2

4 2 4 
1 2 2 4

样例输出 2

1

样例输入 3

2 1 1 
0 0

样例输出 3

1

样例输入 4

2 1 0 
0 0

样例输出 4

-1

说明

对于第 1 个样例,如果你在你到达 2.5 秒后开始会议,前两名下属将参加会议。

对于第 2 个样例,你可以将第三名下属的到达时间推迟一秒。

对于第 3 个样例,你可以将第二名下属的到达时间推迟一秒,并在你到达 0.71863781 秒后开始会议。

对于第 4 个样例,你无法通过调整任何到达时间来满足你的需求。

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.