#C4075. Minimize Skyline Sections

    ID: 47573 Type: Default 1000ms 256MiB

Minimize Skyline Sections

Minimize Skyline Sections

Given a skyline comprised of buildings with various heights, your task is to split the skyline into the fewest possible sections. In each section, every building will share the same color shade, which can only be applied if the building heights are identical.

This can be formulated as follows. Given an integer \( n \) and an array of \( n \) integers \( h_1, h_2, \ldots, h_n \) representing building heights, you are to output the minimum number of sections such that all buildings in each section are of the same height. Essentially, you must determine the number of unique heights. Mathematically, if \( H = \{ h_i : 1 \le i \le n \} \), then the minimal number of sections required is \( |H| \).

inputFormat

The input is given on two lines:

  1. The first line contains a single integer \( n \) (\(1 \le n \le 10^5\)), the number of buildings.
  2. The second line contains \( n \) space-separated integers representing the heights \( h_1, h_2, \ldots, h_n \) of the buildings.

outputFormat

Output a single integer representing the minimum number of sections needed, which is equivalent to the number of distinct building heights.

## sample
5
2 2 1 1 3
3