#BS0000063. Búp bê lồng nhau (Nested Dolls)
Búp bê lồng nhau (Nested Dolls)
Nested Dolls
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Doll fits inside iff and . Partition all dolls into the minimum number of nesting chains.
Input
The first line contains . The second line contains .
Output
Print the minimum number of chains.
Subtasks
- Subtask 1 — 20%: .
- Subtask 2 — 30%: .
- Subtask 3 — 50%: , .
Example
Input
4
20 30 10 10 30 20 40 50
Output
2
Explanation
Two nesting chains are sufficient and one is impossible.