Amplitude Hackathon Summer '25 Problem 5 - Nico the Skydiver

View as PDF

Submit solution

Points: 7 (partial)
Time limit: 0.5s
Memory limit: 1G

Problem type

Nico's going skydiving! Unfortunately, no one knows anything about skydiving, so this problem will gloss over what skydiving actually entails.

Nico has planned out n different skydiving excursions that she wants to pursue. Alas, there are only so many hours in a day, and so Nico might not be able to pursue all of them. Specifically, the i^{\texttt{th}} excursion takes t_i units of time to complete and must be completely done by d_i. Nico wishes to maximize the number of unique excursions she goes on. Help her!

Constraints

1 \le T \le 10^4

1 \le n \le 10^5

1 \le t_i \le d_i \le 10^9

The sum of n over all test cases is at most 10^5.

Subtask 1 [1 point]

T \le 10

n \le 5

d_i \le 2 \cdot 10^3

Subtask 2 [1 point]

T \le 10

n \le 50

d_i \le 2 \cdot 10^3

Subtask 3 [1 point]

No additional constraints.

Input Specification

The first line contains a single integer, T. T test cases follow.

The description for each test case starts with a single integer n, the number of excursions for that test case.

n lines follow, each containing two integers, t_i and d_i, the parameters for the i^{\texttt{th}} excursion.

Output Specification

Output T lines. On the i^{\texttt{th}} line, output the maximum number of unique excursions that Nico can go on.

Sample Input 1

3
4
1 2
2 4
3 6
4 8
4
3 4
1 1
1 1
2 2
3
7 8
3 9
5 10

Sample Output 1

3
2
2

Sample Explanation 1

For the first test case, Nico can pick the first three excursions.

For the second test case, Nico can pick the first two excursions. Note that Nico must pursue the second excursion before the first one.

For the third test case, Nico can pick the third excursion, then the second excursion.


Comments

There are no comments at the moment.