cswork / OAOpen practice workspace

IntuitOA #20

Russian Dolls (Intuit India)

EasyJudge-ready

Topics (AI-labelled)Hashing

Put smaller dolls inside larger ones; dolls of the same size cannot nest inside each other. After nesting as much as possible, output the minimum number of dolls left.

Input

The input gives N (1≤N≤100000), then a line of N sizes (1..100000).

Output

Output the answer as described; for array answers, separate values with spaces.

Example 1

Input:

4
2 2 3 3

Output:

2

Example 2

Input:

6
1 2 2 3 4 5

Output:

2

Example 3

Input:

1
4

Output:

1

Example notes

Count the occurrences of each size; the answer is the maximum frequency.

Correctness: each size appears at most once in any nesting chain, so the most frequent size needs at least that many chains. Conversely, sort the sizes and assign them round-robin by index to that many chains; sizes within each chain strictly increase, so every doll fits into a chain.

Complexity: O(N) time, O(N) space.

Editorial

Loading solution…