#K83732. Aesthetic Garden
Aesthetic Garden
Aesthetic Garden
You are given a garden of n flowers arranged in a row. Each flower has a color represented by an integer. A garden is considered aesthetic if no two adjacent flowers share the same color. Your task is to determine the minimum number of changes needed to make the garden aesthetic.
Explanation: For every pair of adjacent flowers with the same color, you must change one of them. Note that when a change is made, the new color can be any integer value that does not equal its adjacent neighbor’s color. In this problem, you can simulate this by assigning a dummy value to break the equality.
Mathematical formulation: Find the minimum count c such that for the sequence of colors \(a_1, a_2, \ldots, a_n\), after at most \(c\) modifications, \(a_i \neq a_{i+1}\) for all \(1 \leq i < n\).
inputFormat
The input is read from standard input (stdin) and consists of two lines.
- The first line contains an integer
n
, the number of flowers. - The second line contains
n
space-separated integers representing the colors of the flowers.
outputFormat
Output a single integer to standard output (stdout) representing the minimum number of changes required to ensure that no two adjacent flowers have the same color.
## sample6
2 2 2 3 3 4
2