QOJ.ac

QOJ

Límite de tiempo: 6 s Límite de memoria: 1024 MB Puntuación total: 100 Hackeable ✓

#14230. 速通

Estadísticas

你渴望成为一名顶尖的《我的世界》(Minecraft)生存速通(speedrun)玩家。因此,你需要制定一个策略,快速且高效地完成所有必要的任务。在观看了许多以前的世界纪录速通视频后,你注意到第一天是最关键的。

为了使速通成功,你需要在《我的世界》的第一天内完成至少 $G$ 个任务。《我的世界》中的一天长达 $24\,000$ 刻(ticks),因此,为了成为一名真正的游戏玩家,你决定用《我的世界》的术语来进行计算。你一次只能进行一个任务,并且在完成当前任务之前不能开始另一个任务。每个任务只能在特定的时间段 $0 \le t_{start} < t_{end} \le 24\,000$ 内完成。注意:只要一个任务的开始时间大于或等于前一个任务的结束时间,该任务就可以被安排,且不会产生冲突。

给定 $G$(你在《我的世界》第一天需要完成的最少任务数)、$N$(你可以选择完成的任务总数)以及它们对应的时间段,请判断这次速通是否有可能成功。

输入格式

第一行包含两个由空格分隔的整数 $0 < G \le N < 10^5$,分别表示你在第一天需要完成的任务数和可选择的任务总数。

接下来的 $N$ 行,每行包含两个整数 $t_{start}$ 和 $t_{end}$,表示一个任务的开始时间和结束时间,其中 $0 \le t_{start} < t_{end} \le 24\,000$。

输出格式

如果这次速通有可能成功,输出 "YES";否则,输出 "NO"。

样例

输入样例 1

2 3
0 20
20 24000
19 21

输出样例 1

YES

输入样例 2

2 4
3 5
1 4
4 24000
0 17000

输出样例 2

YES

输入样例 3

3 4
1 501
500 1001
1000 1501
1500 2000

输出样例 3

NO

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.