#K70587. Garland Decoration Challenge
Garland Decoration Challenge
Garland Decoration Challenge
You are given a garland of n bulbs, each colored with one of k colors. Your task is to determine whether it's possible to decorate the entire garland such that no two adjacent bulbs have the same color.
The input provides the number of bulbs n, the number of available colors k, followed by a sequence of n integers representing the colors of the bulbs in order.
Note: Two bulbs are considered adjacent if they are consecutive in the sequence. The garland is deemed properly decorated if for every adjacent pair, their colors differ.
The answer should be YES
if the garland meets the criteria and NO
otherwise.
This problem involves a simple sequential check and is rated as easy in difficulty.
inputFormat
The input is given via stdin in the following format:
n k b1 b2 ... bn
Where:
- n is the number of bulbs.
- k is the number of colors.
- bi is the color of the i-th bulb.
outputFormat
Output a single line to stdout:
YES
or
NO
depending on whether it is possible to decorate the garland without any two adjacent bulbs sharing the same color.
## sample5 3
1 2 1 3 2
YES
</p>