#C435. Tallest Box Stack
Tallest Box Stack
Tallest Box Stack
You are given a collection of boxes. Each box is described by an identification number and a weight. Your task is to determine the maximum height of a stack that can be formed under the following conditions:
- A heavier box cannot be placed on top of a lighter box. In other words, if box A is placed on box B then \(\text{weight}(A) \le \text{weight}(B)\).
- No two boxes in the same stack can have the same identification number.
You are allowed to reorder the boxes arbitrarily to form a valid stack. Essentially, you need to select at most one box per unique identification number. The maximum height is equal to the number of unique boxes selected. Note that boxes with equal weights can be stacked in any order as the condition only prevents a heavier box from being placed above a lighter one.
inputFormat
The input is provided via standard input (stdin). The first line contains an integer \(n\) representing the number of boxes. This is followed by \(n\) lines, each containing two space-separated integers: the identification number and the weight of a box.
outputFormat
Output a single integer (followed by a newline) to standard output (stdout), representing the maximum height of the stack that can be formed.
## sample5
1 5
2 7
3 6
1 4
3 10
3
</p>