题目:

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. 快速入门脑机接口:BCI基础(二)
  2. 一周一论文(翻译 总结)—— [SOSP 18] LITE Kernel RDMA Support for Datacenter Applications : 一个LITE 内核支持的RDMA通信库
  3. msm8937+android7.1系统播放某个MP4文件在data分区下创建ramdump并生成很多elf文件问题
  4. 基于koa2开发的用户中心
  5. constexpr函数
  6. MyEclipse远程调试Tomcat
  7. 《AlphaGo世纪对决》与周志华《机器学习》观后感
  8. 一直在构建版本_教你如提升Gradle90%的构建速度
  9. [凯立德]2015春季版C2739-M7L83-3521JON,已O+带3D+带路况
  10. Spring Boot使用自定义的properties
  11. Django_3_路由
  12. thinkphp5.0 session驱动方式问题汇总
  13. 遗传算法C语言实现以及思路详解简单易懂
  14. 问题:检测到远端X服务正在运行中(CVE-1999-0526)
  15. 开源开放 | 欧若科技通过 OpenKG 开放 Nebula Graph 图数据库
  16. 书籍《图说区块链》读后感
  17. c语言向量乘法,运用C语言实现向量积
  18. CPU 工作原理(附详细图解)
  19. IDEA找不到应用程序(localhost:8080)
  20. 通用视觉预训练大模型巡礼系列(一):UFO大模型

热门文章

  1. ngx_http_core_module模块提供的变量
  2. Uipath 安装Chrome插件
  3. 新爹手记-分娩篇-出生前一天(原汁原味流水版)
  4. QT实现图片缩放的同时标记指定坐标
  5. 光耦电流传输比(CTR)的理解
  6. 详谈Office365和Office2019的版本与区别
  7. 40种让孩子爱上阅读的好方法!转给家长
  8. 360 os3.0 android7.1,360OS 3.0系统
  9. 医学计算机论文,医学图像数据库-外文翻译(计算机论文,医学论文适合)
  10. 【谷粒学院项目开发44】课程大纲——小节的添删