307008: CF1286A. Garland
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Garland
题意翻译
有一个由$1$-$n$构成的数列,其中部分被删除(删除的元素由$0$代替),请用被删除的元素补全这个数列,使这个数列中相邻元素奇偶性不同的对数最少。题目描述
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $ n $ light bulbs in a single row. Each bulb has a number from $ 1 $ to $ n $ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the garland. Now Vadim wants to put them back on. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1286A/44ebad0b7dea7f3147d7078591406d3a6ec6de35.png)Vadim wants to put all bulb back on the garland. Vadim defines complexity of a garland to be the number of pairs of adjacent bulbs with numbers with different parity (remainder of the division by $ 2 $ ). For example, the complexity of 1 4 2 3 5 is $ 2 $ and the complexity of 1 3 5 7 6 4 2 is $ 1 $ . No one likes complexity, so Vadim wants to minimize the number of such pairs. Find the way to put all bulbs back on the garland, such that the complexity is as small as possible.输入输出格式
输入格式
The first line contains a single integer $ n $ ( $ 1 \le n \le 100 $ ) — the number of light bulbs on the garland. The second line contains $ n $ integers $ p_1,\ p_2,\ \ldots,\ p_n $ ( $ 0 \le p_i \le n $ ) — the number on the $ i $ -th bulb, or $ 0 $ if it was removed.
输出格式
Output a single number — the minimum complexity of the garland.
输入输出样例
输入样例 #1
5
0 5 0 2 3
输出样例 #1
2
输入样例 #2
7
1 0 0 5 0 0 2
输出样例 #2
1