Problem A
Awkward Party
Martin has invited everyone he knows to celebrate his 535th
birthday, and a whopping
When deciding the seating arrangement, Martin’s mother Margarethe have decided that all the guests should be seated with maximum awkwardness; this is to ensure that nobody has anything meaningful to discuss during dinner, and everyone would instead silently enjoy her rather tasty coriander soup (as the saying goes; “when the food is good, conversation dies”).
Margarethe knows that awkwardness is maximized if the guests
are seated in a long row along a single table, in such a way
that nobody sits next to someone speaking the same language as
themselves. Better yet, she has defined the awkwardness
level of a seating arrangement to be the minimum number of
seats separating any two guests speaking the same language. If
no two people speak the same language, the awkwardness level is
defined to be
Given the languages spoken in a proposed seating arrangement, can you help Margarethe determine the awkwardness level?
Input
The first line contains an integer
Output
A single integer, the awkwardness level of the proposed seating arrangement.
Sample Input 1 | Sample Output 1 |
---|---|
4 1 2 3 1 |
3 |
Sample Input 2 | Sample Output 2 |
---|---|
3 1 2 3 |
3 |