QOJ.ac

QOJ

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

#14884. 考试学习规划

Estadísticas

你今天有很多场考试!而你还没有为其中任何一场做好准备!至少根据经验,你深知如果为某场考试复习了足够的时间,你就一定能快速通过它,且远在规定的时间内。更棒的是,你盯着那令人望而生畏的课程大纲看了很久,现在已经确切地知道每场考试需要复习多长时间才能在规定时间内通过。如果你复习的时间不够长,你就一定会挂科。

Pixabay Content License by Andrew Tan on Pixabay

碰巧的是,你们学校有一些奇怪的官僚规定,要求你必须参加所有的考试。真是太可怕了!而且除非你确信自己已经通过了考试,否则是不允许提前离场的!

给定完整的考试时间表,包括每场考试的开始时间、每场考试持续的时间、你为每场考试复习所需的时间,以及如果你复习了,你能多快完成该考试。你最多可以通关多少场考试?

你可以在时刻 $0$ 开始复习,但只能在不考试的时候复习。某场考试的复习准备工作不需要在连续的时间段内完成,可以被中断。

输入格式

输入包含:

  • 第一行包含一个整数 $n$ ($1 \le n \le 2000$),表示你需要参加的考试数量。
  • 接下来的 $n$ 行,第 $i$ 行包含四个整数,用于描述第 $i$ 场考试:

    • $s_i$ ($0 \le s_i$),第 $i$ 场考试的开始时间。
    • $p_i$ ($s_i < p_i$),如果你为第 $i$ 场考试做了复习,该考试的结束时间。
    • $e_i$ ($p_i \le e_i \le 10^9$),如果你没有为第 $i$ 场考试做复习,该考试的结束时间。
    • $a_i$ ($1 \le a_i \le 10^9$),复习第 $i$ 场考试所需的时间。

这些考试按开始时间的升序给出,且互不重叠,即对于 $1 \le i < n$,满足 $e_i \le s_{i+1}$。

输出格式

输出你最多可以通关的考试数量。

样例

输入样例 1

3
10 20 30 5
30 50 100 15
100 101 200 50

输出样例 1

3

输入样例 2

3
1000 1001 1002 1000
1003 1004 1005 500
1006 1007 1008 500

输出样例 2

2

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.