荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: huhaiming (一生只爱她), 信区: Program
标  题: 1007 Switch
发信站: 荔园晨风BBS站 (Sun Jun  8 19:28:43 2003), 站内信件

Switch

Time limit: 1 Seconds   Memory limit: 32768K
Total Submit: 312   Accepted Submit: 159

There are N lights in a line. Given the states (on/off) of the lights,
your task is to determine at least how many lights should be switched
(from on to off, or from off to on), in order to make the lights on
and off alternatively.

Input

One line for each testcase.

The integer N (1 <= N <= 10000) comes first and is followed by N
integers representing the states of the lights ("1" for on and "0" for
off).

Process to the end-of-file.


Output

For each testcase output a line consists of only the least times of
switches.


Sample Input

3 1 1 1
3 1 0 1


Sample Output

1
0


Author: SHI, Xiaohan



--

菩提本无树,明镜亦非台

本来无一物,何处惹尘埃

※ 来源:·荔园晨风BBS站 bbs.szu.edu.cn·[FROM: 192.168.0.200]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店