#C11416. Maximum Non-Overlapping Meetings

    ID: 40730 Type: Default 1000ms 256MiB

Maximum Non-Overlapping Meetings

Maximum Non-Overlapping Meetings

You are given a collection of meetings, each with a start time and an end time. Your task is to determine the maximum number of meetings that can be scheduled in a single room without overlapping. Two meetings are considered non-overlapping if the start time of one is greater than or equal to the end time of the previous meeting. Formally, if the meetings are represented as intervals \([s_i, e_i]\), then meeting \(j\) can follow meeting \(i\) if \(s_j \ge e_i\).

Input Format (STDIN):
The first line contains an integer T, the number of test cases. Each test case begins with an integer N, the number of meetings. The following N lines each contain two space-separated integers s and e, representing the start and end times of a meeting.

Output Format (STDOUT):
For each test case, output a single line containing one integer: the maximum number of non-overlapping meetings that can be scheduled in the room.

Example:

Input:
2
3
1 4
2 3
3 5
4
1 2
3 4
0 6
5 7

Output: 2 3

</p>

inputFormat

The input is read from standard input (STDIN) and is structured as follows:

  • The first line contains an integer T, representing the number of test cases.
  • For each test case, the first line contains an integer N, the number of meetings.
  • Then follow N lines, each with two integers s and e separated by a space, denoting the start time and end time of a meeting.

outputFormat

For each test case, output one integer on a new line: the maximum number of non-overlapping meetings that can be scheduled in one room.

## sample
2
3
1 4
2 3
3 5
4
1 2
3 4
0 6
5 7
2

3

</p>