题目:

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 nninteger numbers a1,a2,…,ana1,a2,…,an, where ai=1ai=1 if in the ii-th flat the light is on and ai=0ai=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 ai−1=ai+1=1ai−1=ai+1=1 and ai=0ai=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.

Input

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

The second line of the input contains nn integers a1,a2,…,ana1,a2,…,an (ai∈{0,1}ai∈{0,1}), where aiaiis the state of light in the ii-th flat.

Output

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

Examples

Input

10
1 1 0 1 1 0 1 0 1 0

Output

2

Input

5
1 1 0 0 0

Output

0

Input

4
1 1 1 1

Output

0

Note

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.

解题报告:数据出水了,所以直接暴力就可以ac 。如果一个不开灯的人两边都是开灯的话,他无法正常入眠,问至少关闭需要关闭多少灯才可以!

ac代码:

#include<bits/stdc++.h>
using namespace std;int num[155];
int main()
{int n;int cnt=0;scanf("%d",&n);for(int i=0;i<n;i++)scanf("%d",&num[i]);for(int i=1;i<n-1;i++){if(num[i-1]==1&&num[i]==0&&num[i+1]==1){cnt++;num[i+1]=0;}}printf("%d\n",cnt);
}

【Disturbed People】【CodeForces - 1077B】(思维水题)相关推荐

  1. codeforces 1060a(思维水题)

    Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", ...

  2. FZU 2230 2230 翻翻棋(思维水题)

    Problem Description 象棋翻翻棋(暗棋)中双方在4*8的格子中交战,有时候最后会只剩下帅和将.根据暗棋的规则,棋子只能上下左右移动,且相同的级别下,主动移动到地方棋子方将吃掉对方的棋 ...

  3. B - Average Numbers CodeForces - 134A(水题,思维)

    You are given a sequence of positive integers a1, a2, -, an. Find all such indices i, that the i-th ...

  4. CF Round #426 (Div. 2) The Useless Toy 思维 水题

    题目链接: http://codeforces.com/contest/834/problem/A 题目描述: 输入起始状态和结束状态和数列长度, 判断旋转方向是顺时针逆时针还是不合理 解题思路: 长 ...

  5. Codeforces数据结构(水题)小结

    最近在使用codeblock,所以就先刷一些水题上上手 使用codeblock遇到的问题 1.无法进行编译-------从setting中的编译器设置中配置编译器 2.建立cpp后无法调试------ ...

  6. A - System Administrator CodeForces - 245A(水题)

    Polycarpus is a system administrator. There are two servers under his strict guidance - a and b. To ...

  7. Letters CodeForces - 978C(水题,low_bound()函数使用)

    水题,记录一下low_bound(*begin,*end,num),其中low-bound是指以num为下界,寻找第一个比num大或相等的元素的指针,通过减去*begin指针我们可以获得相应的下标. ...

  8. 【CodeForces - 707B】Bakery(思维水题)

    Bakery Descriptions 玛莎想在从1到n的n个城市中开一家自己的面包店,在其中一个城市烘焙松饼. 为了在她的面包房烘焙松饼,玛莎需要从一些储存的地方建立面粉供应.只有k个仓库,位于不同 ...

  9. CodeForces - 622C Not Equal on a Segment(思维+水题)

    题目链接:点击查看 题目大意:先给出一个长度为n的数列,然后给出m次询问,每次询问的格式是l,r,x,其中[l,r]代表的是数列的下标范围,要求我们输出任意一个在区间[l,r]内值不等于x的下标 题目 ...

最新文章

  1. 华为程序员发现孩子不是自己的!怒提离婚!但老婆只要房子车子!不要孩子!绿他的竟然是个酒吧混混!...
  2. 什么是生存分析(survival analysis)?
  3. MySQL数据类型(最大值 和 最小值)
  4. YII1 MVC初认识(二)
  5. python实现冒泡排序算法的非递归版本_python排序算法速度比较:快速排序,归并排序,冒泡排序...
  6. 科大星云诗社动态20210820
  7. 学习Spring Boot:(十二)Mybatis 中自定义枚举转换器
  8. image是否有disabled属性_8、背景属性
  9. 甲骨文前高管跳槽至富士通 主抓企业级存储
  10. java 构造函数嵌套_java – spring – 构造函数注入和覆盖嵌套bean的父定义
  11. 领域建模——事件风暴
  12. java缓存机制面试题,电子版已问世
  13. 2021软件测试技能大赛,2021软件测试国赛获奖感言
  14. Android APP登录界面
  15. 2022年P气瓶充装考题及答案
  16. 冒志鸿:大公司不模仿你,说明你危险了
  17. Linux中如何优雅的批量合并、拆分、加密pdf文件
  18. 伺服电机各种运行模式
  19. 如何使用DDC保管箱
  20. 以 SPI 方式获取 SD 卡容量(V2.0)

热门文章

  1. php错误处理视频教程,PHP错误与异常调试视频教程资源分享
  2. 黑马程序员各学科超长体验课知识点汇总
  3. 生物识别技术是什么,生物识别技术的比较介绍
  4. 「系统介绍」简单介绍下PMS系统
  5. 什么是逻辑地址,什么是物理地址,为什么要进行二者的转换工作?
  6. 中国晒2018经济成绩单 GDP、收入、就业等指标亮眼
  7. ThrustMaster HOTAS WARTHOG飞行摇杆评测
  8. 关于Android 9 隐藏虚拟按键的问题
  9. 小学计算机管理员教学计划,小学教学计划汇总六篇
  10. 【论文合集】2022年10月医学影像期刊论文合集