Blockchain

0

0 votes
Problem

As we all know, blockchain technology is mostly used to develop a decentralized application. 
A blockchain is a chain of connected block such that each block keeps the hash of its previous block.
You are given a list of blocks represented by pair of numbers. You have to find the maximum length that can be made by connecting these blocks.
The rule for connecting the blocks is:
Suppose a pair (x,y) is followed by (m,n). Then y must be less than m.

 

Input format:

  • First line contains n (number of pairs).
  • Each of the next n lines contains a and b separated by space of pair (a,b).
  • Every pair will be in the form (a,b) where a<b.

 

Output Format:

Print the maximum length of blockchain that can be made.

Constraint

1n1051a,b105

Sample Input
5
5 24
39 60
15 28
27 40
50 90
Sample Output
3
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Longest chain would be formed by (5,24), (27,40) and (50,90)

Contributers:
Editor Image

?