QOJ.ac

QOJ

حد الوقت: 3.0 s حد الذاكرة: 512 MB مجموع النقاط: 100

#18341. 缺勤

الإحصائيات

旷工是指在没有正当理由的情况下,习惯性地缺席职责或义务的行为。

—— 维基百科

Alex 在公司工作。有 $n$ 名员工与他共事。与 Alex 不同,他们严格遵守自己的工作时间表:第 $i$ 名员工在时刻 $a_i$ 上班,并在时刻 $b_i$ 下班($a_i < b_i$)。

Alex 必须不早于时刻 $0$ 上班,不晚于时刻 $m$ 下班,并且每天需要工作 $k$ 小时($k \le m$)。但当然,他希望工作的时间越少越好。问题在于,他的同事们不喜欢懒惰的人,如果其中任何人发现 Alex 一天的工作时间少于 $k$ 小时,他们就会向老板投诉,Alex 就会被解雇。

换句话说,假设 Alex 在时刻 $x$ 上班,并在时刻 $y$ 下班,其中 $0 \le x < y \le m$。那么,如果满足以下条件中的至少一个,Alex 就会面临被投诉的危险:

  • $y - x < k$,且存在一名员工 $i$ 满足 $a_i \le x$ 且 $y \le b_i$(即区间 $[x, y]$ 完全包含在 $[a_i, b_i]$ 内)——在这种情况下,第 $i$ 名员工亲眼看到 Alex 工作少于 $k$ 小时;
  • 存在一名员工 $i$ 满足 $x < a_i \le y \le b_i$,且 $y < k$ ——在这种情况下,第 $i$ 名员工看到 Alex 在时刻 $k$ 之前就下班了;
  • 存在一名员工 $i$ 满足 $a_i \le x \le b_i < y$,且 $x > m - k$ ——在这种情况下,第 $i$ 名员工看到 Alex 在时刻 $m - k$ 之后才来上班;
  • 存在一名员工 $i$ 满足 $y < a_i$ 或 $b_i < x$(即区间 $[x, y]$ 和 $[a_i, b_i]$ 不相交),且 $a_i \le k$ 且 $b_i \ge m - k$ ——在这种情况下,第 $i$ 名员工完全没有在工作中看到 Alex,但这正是他们得出 Alex 不可能工作满 $k$ 小时的依据。

在没有同事向老板投诉的前提下,Alex 最少需要在工作上花费多少时间?

输入格式

第一行包含三个整数 $n, m, k$($1 \le n \le 10^5$,$1 \le m \le 10^9$,$1 \le k \le m$),分别表示与 Alex 共事的员工人数、一天的长度以及 Alex 每天需要工作的小时数。

接下来的 $n$ 行,每行包含两个整数 $a_i$ 和 $b_i$($0 \le a_i < b_i \le m$),表示第 $i$ 名员工上班和下班的时刻。

输出格式

如果 Alex 可以完全不用来上班,输出 -1 -1

否则,输出两个整数 $x, y$($0 \le x < y \le m$,$y - x \le k$),表示 Alex 应该上班和下班的时刻,使得没有同事向老板投诉,且工作时间($y - x$)最小。

如果有多个可能的解,输出其中任意一个。

样例

输入样例 1

2 20 10
0 12
8 20

输出样例 1

7 13

输入样例 2

2 20 18
0 10
10 20

输出样例 2

2 18

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.