QOJ.ac

QOJ

Time Limit: 30.0 s Memory Limit: 256 MB Total points: 100

#17374. 两位教授

Statistics

在伟大的 X 学院有两位教授,他们非常不合。为了不透露他们的名字,我们称他们为 1 和 2。学院一共雇用了 $n$ 位教授,每位教授都必须恰好进行一场讲座。由于他们的日程安排相当紧凑(记住,他们可是教授!),每场讲座的开始和结束时间已经固定。然而,每场讲座在哪个教室进行尚未确定。显然,如果两场讲座的时间段重叠,就不能将它们安排在同一个教室;另一方面,如果其中一场讲座的开始时间恰好等于另一场讲座的结束时间,则是允许的。你的任务是求出能够安排所有讲座所需的最少教室数量。但请注意,教授 1 和教授 2 非常讨厌彼此,以至于他们绝不能在同一个教室里进行讲座。

输入格式

输入包含多个测试用例。第一行包含测试用例的数量 $t$ ($t \le 250$)。每个测试用例的第一行包含教授的数量 $n$ ($2 \le n \le 10^5$)。接下来的 $n$ 行中,第 $i$ 行包含两个整数 $start_i$ 和 $end_i$ ($0 \le start_i < end_i \le 10^9$),分别表示第 $i$ 位教授讲座的开始和结束时间。输入数据的总大小不会超过 50MB。

输出格式

对于每个测试用例,输出安排所有讲座所需的最少教室数量。

样例

输入样例 1

4
2
0 10
10 20
3
0 10
10 20
10 20
5
4 14
3 13
2 12
1 11
0 10
4
0 10
10 20
20 30
30 40

输出样例 1

2
2
5
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.