Submit solution


Points: 200.00 (partial)
Time limit: 1.0s
Memory limit: 1G
Input: stdin
Output: stdout

Author:
Problem types
Allowed languages
C, C++, GAS64, Pascal, Perl, PHP, Python, Sed, TCL, Text

P loves music and has been learning about it since a very young age. Despite being such a smart boy, he found himself struggling to understand music theory. However, this causes no dent on P's burning passion for such art. Thus, he decided to invent his own system of music theory. According to his system, a song would consist of notes. Each note will be differentiated by two values, its pitch and duration. Pitch would be a positive integer ranged from ~1~ to ~M~, while duration would be a positive integer ranged from ~1~ to ~K~. A "catchy" song would be a song whose notes have non-decreasing pitch and non-increasing duration. To illustrate, consider a song with ~N~ notes whose pitch is ~a_i~ and duration is ~b_i~, the song would be "catchy" if and only if ~a_i \leq a_{i+1}~ và ~b_i \geq b_{i+1} (1 \leq i < N)~. After creating a music system of his own, P coudn't wait to compose his own song consisting of ~N~ notes. It was only after completion that he realized his piece wasn't as "catchy" as he wanted. Reluctant to write another tune, he decided to delete some (probably zero) continuous subsequences of notes, so that the song with the remaining notes would be "catchy".Despite it being such a simple task for P, deleting his first brainchild makes P's heart break :(. So now he asks you to do the task instead. Help P delete some (probably zero) continuous subsequences of notes, so that the song with the remaining notes would be "catchy" and has the the longest possible length.

INPUT:

  • First line of the input contains 3 positive integer ~N~, ~M~, ~K~.
  • Each of the next ~N~ lines contains 2 positive integer ~a_i~ and ~b_i~, the pitch and duration of the ~i~-th note (~1 \leq i \leq N~).

OUTPUT:

  • The longest length of the song after deleting

EXAMPLE


Input 1

5 5 5
1 5
4 2
1 4
2 3
5 1


Output 1

4

Input 2

4 2 2
2 2
1 1
1 1
1 1

Output 2

3

Subtask 1: ~20\%~ number of tests have ~N \leq 20, M,K \leq 20~

Subtask 2: ~20\%~ number of tests have ~N \leq 1000, M,K \leq 1000~

Subtask 3: ~20\%~ number of tests have ~N \leq 100000, M \leq 1000, K=1~

Subtask 4: ~20\%~ number of tests have ~N \leq 100000, M,K \leq 20~

Subtask 5: ~20\%~ number of tests have ~N \leq 100000, M,K \leq 1000~


Comments

Please read the guidelines before commenting.