#K37087. Maximum Block Stack Height

    ID: 25898 Type: Default 1000ms 256MiB

Maximum Block Stack Height

Maximum Block Stack Height

You are given a set of blocks, each with a specific size. Your task is to build the tallest stack possible using all the available blocks under the following constraint:

Each block can only be placed on top of another block whose size is at least as large as its own. In other words, if a block of size \(a\) is placed on top of a block of size \(b\), then it must hold that \(a \le b\).

You can rearrange the blocks in any order. Determine the maximum height of the stack that can be built.

Note: The input will first provide an integer \(n\) denoting the number of blocks followed by \(n\) space-separated integers representing the sizes of the blocks. The answer is simply \(n\) since by sorting the blocks in descending order (so that each block is placed on a block with a larger or equal size) all blocks can be used.

Formally, given an array \(B\) of \(n\) integers, the goal is to compute the maximum stack height \(H\) such that \(H = n\) when the blocks are arranged in an order satisfying \(B[i] \le B[i-1]\) for every \(i = 2, \ldots, n\).

inputFormat

The input is read from standard input and has the following format:

n
s1 s2 ... sn

where \(n\) is the number of blocks and \(s1, s2, \dots, sn\) are the sizes of the blocks.

outputFormat

Output a single integer representing the maximum height of the block stack that can be built, which is simply \(n\) if all blocks can be used.

## sample
5
3 4 2 1 2
5