#C10932. Pen Distribution
Pen Distribution
Pen Distribution
Given a sequence of pens where each pen is painted with a specific color, determine whether the pens can be distributed in the given order so that no two adjacent pens have the same color. Formally, you are given an integer \(n\) representing the number of pens, followed by a sequence of \(n\) integers denoting the color codes of each pen. If any two consecutive pens share the same color, the answer should be No
; otherwise, Yes
should be output.
inputFormat
The input consists of two lines. The first line contains a single integer \(n\) (\(1 \leq n \leq 10^5\)), representing the number of pens. The second line contains \(n\) integers separated by spaces, where each integer represents the color code of a pen.
outputFormat
Output a single line with either Yes
if no two adjacent pens have the same color, or No
if at least one pair of consecutive pens share the same color.
5
1 1 2 3 3
No