Noor and his pond
Practice
4 (39 votes)
Algorithms
Medium
Quick sort
Sorting
Problem
82% Success 16790 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Statement

Noor is going fish farming. There are N types of fish. Each type of fish has size(S) and eating factor(E). A fish with eating factor of E, will eat all the fish of size $$ \le E $$.

Help Noor to select a set of fish such that the size of the set is maximized as well as they do not eat each other.

Constraints

$$ 1 \le T \le 3 $$

$$ 1 \le N \le 100000 $$

$$ 1 \le S_i , E_i \le  10^9 $$

$$ S_i > E_i $$ 

Input

The first line contains T, the number of test cases. The first line of a test case contains an integers N. N is the number of types of fish. Each of the next N lines contains two integers S and E meaning the size and eating factor of a fish.

Output

For each test cases, print a single integer, the maximum number of fish Noor can have in his pond. 

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
14 votes
Tags:
Ad-HocAlgorithmsApprovedMediumOpenSorting