CF1077B.Disturbed People

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There is a house with nn flats situated on the main street of Berlatov. Vova is watching this house every night. The house can be represented as an array of nn integer numbers a1,a2,,ana_1, a_2, \dots, a_n , where ai=1a_i = 1 if in the ii -th flat the light is on and ai=0a_i = 0 otherwise.

Vova thinks that people in the ii -th flats are disturbed and cannot sleep if and only if 1<i<n1 < i < n and ai1=ai+1=1a_{i - 1} = a_{i + 1} = 1 and ai=0a_i = 0 .

Vova is concerned by the following question: what is the minimum number kk such that if people from exactly kk pairwise distinct flats will turn off the lights then nobody will be disturbed? Your task is to find this number kk .

输入格式

The first line of the input contains one integer nn ( 3n1003 \le n \le 100 ) — the number of flats in the house.

The second line of the input contains nn integers a1,a2,,ana_1, a_2, \dots, a_n ( ai{0,1}a_i \in \{0, 1\} ), where aia_i is the state of light in the ii -th flat.

输出格式

Print only one integer — the minimum number kk such that if people from exactly kk pairwise distinct flats will turn off the light then nobody will be disturbed.

输入输出样例

  • 输入#1

    10
    1 1 0 1 1 0 1 0 1 0
    

    输出#1

    2
    
  • 输入#2

    5
    1 1 0 0 0
    

    输出#2

    0
    
  • 输入#3

    4
    1 1 1 1
    

    输出#3

    0
    

说明/提示

In the first example people from flats 22 and 77 or 44 and 77 can turn off the light and nobody will be disturbed. It can be shown that there is no better answer in this example.

There are no disturbed people in second and third examples.

首页