4450: Taking Photo
内存限制:128 MB
时间限制:2 S
标准输入输出
题目类型:传统
评测方式:Special Judge
上传者:
提交:0
通过:0
题目描述
There are some people from a company sitting in a line and waiting to take a group photo. For some reason, the people coming from the same department want to sit together, i.e., sit in some continuous seats. Note that the seats cannot be moved, but they can change seats with others. Now, they need your help to figure out the minimum number of people involved in changing seats.
输入格式
There will be at most 200 test cases. Each case begins with one integer n(3 ≤ n ≤ 30), the number of the people. The next line contains n integers xi(1 ≤ xi ≤ n), describing the department identifiers of the people from left to right. People with the same identifier belong to the same department.
输出格式
For each test case, print the minimum number of people involved in changing seats.
输入样例 复制
6
5 2 5 2 1 5
7
1 5 1 2 7 2 2
6
2 1 1 4 3 3
输出样例 复制
3
3
0