#P7261. Beautiful Photo

    ID: 20461 Type: Default 1000ms 256MiB

Beautiful Photo

Beautiful Photo

In the enchanted forest, Snow White takes photos of the dwarfs as they head to the mine. There are n dwarfs in a long line, each wearing a colored hat chosen from c different colors. Every morning, as the dwarfs enter the mining area one by one, Snow White captures a photo of all the dwarfs present so far. In particular, the m-th photo will contain exactly m dwarfs.

A photo is defined as beautiful if there exists a hat color that appears in strictly more than \(\frac{m}{2}\) of the dwarfs in that photo. Your task is to determine whether the m-th photo is beautiful and, if it is, report the dominant hat color.

inputFormat

The first line contains three integers, n, c, and m (with \(1 \le m \le n\)), where n is the total number of dwarfs, c is the number of distinct hat colors, and m is the index of the photo to check.

The second line contains n space-separated integers representing the hat colors of the dwarfs in the order they stand. Each color is an integer between 1 and c.

outputFormat

If the m-th photo is beautiful, print YES followed by a space and the dominant hat color.

If it is not beautiful, print NO.

sample

5 3 4
1 2 1 1 3
YES 1