#C3785. Minimum Repaints to Avoid Adjacent Genres

    ID: 47250 Type: Default 1000ms 256MiB

Minimum Repaints to Avoid Adjacent Genres

Minimum Repaints to Avoid Adjacent Genres

You are given n books arranged in a row. Each book is assigned a genre represented by an integer. The goal is to repaint the minimum number of books so that no two adjacent books have the same genre.

When repainting a book, you can change its genre to any integer from 1 to 10 (inclusive), with the constraint that the new genre must be different from its adjacent books. Formally, if the genre of the book at position i is repainted to \(g\), then it must satisfy \(g \neq genre[i-1]\) (and if \(i+1\) exists, \(g \neq genre[i+1]\)).

Your task is to compute the minimum number of repaints required so that no two adjacent books have the same genre.

Input Constraints: \(n \ge 1\). If \(n = 1\), no repaint is needed.

inputFormat

The input is given via standard input (stdin) and consists of:

  • A single integer \(n\) representing the number of books.
  • A line with \(n\) space-separated integers, where the \(i\)-th integer represents the genre of the \(i\)-th book.

outputFormat

Output a single integer via standard output (stdout) indicating the minimum number of repaints required so that no two adjacent books have the same genre.

## sample
5
1 2 1 2 1
0

</p>