All Tracks Algorithms Sorting Quick Sort Problem

Noor and his pond
Tag(s):

Algorithms, Medium, Quick Sort, Quicksort, Quicksort, Quicksort, Sorting

Problem
Editorial
Analytics

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. 

SAMPLE INPUT
1
3
4 1
5 4
7 3
SAMPLE OUTPUT
2
Explanation

In the sample input, Noor can select the first and the third fish.

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

HackerEarth

Challenge Name

August Circuits '18

OTHER PROBLEMS OF THIS CHALLENGE
通知
View All Notifications

?