http://codeforces.com/contest/1077/problem/B

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,…,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 aiai is the state of light in the ii-th flat.

Output

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.

Examples
input

Copy
10
1 1 0 1 1 0 1 0 1 0
output

Copy
2
input

Copy
5
1 1 0 0 0
output

Copy
0
input

Copy
4
1 1 1 1
output

Copy
0

题解:刚开始没看懂题意后来找了翻译 炒鸡简单 如果 a[i] = 0 && a[i - 1] = 1 && a[i + 1] = 1 那么 i 会被影响 应该关掉 a[i + 1] 的灯,即变成 $0$

代码:

#include <bits/stdc++.h>
using namespace std; const int maxn = 1e5 + 10;
int n;
int a[maxn]; int main() {
scanf("%d", &n);
for(int i = 1; i <= n; i ++)
scanf("%d", &a[i]); int ans = 0;
for(int i = 2; i < n; i ++) {
if(a[i] == 0 && a[i - 1] == 1 && a[i + 1] == 1) {
ans ++;
a[i + 1] = 0;
}
}
printf("%d\n", ans);
return 0;
}

  

让人捉鸡的英语理解能力。。。难受

CodeForces Round #521 (Div.3) B. Disturbed People的更多相关文章

  1. Codeforces Round #521 (Div. 3) E. Thematic Contests(思维)

    Codeforces Round #521 (Div. 3)  E. Thematic Contests 题目传送门 题意: 现在有n个题目,每种题目有自己的类型要举办一次考试,考试的原则是每天只有一 ...

  2. Codeforces Round #521 (Div. 3) D. Cutting Out 【二分+排序】

    任意门:http://codeforces.com/contest/1077/problem/D D. Cutting Out time limit per test 3 seconds memory ...

  3. CodeForces Round #521 (Div.3) E. Thematic Contests

    http://codeforces.com/contest/1077/problem/E output standard output Polycarp has prepared nn competi ...

  4. CodeForces Round #521 (Div.3) D. Cutting Out

    http://codeforces.com/contest/1077/problem/D You are given an array ss consisting of nn integers. Yo ...

  5. Codeforces Round #521 (Div. 3) F1. Pictures with Kittens (easy version)

    F1. Pictures with Kittens (easy version) 题目链接:https://codeforces.com/contest/1077/problem/F1 题意: 给出n ...

  6. CodeForces Round #521 (Div.3) A. Frog Jumping

    http://codeforces.com/contest/1077/problem/A A frog is currently at the point 00 on a coordinate axi ...

  7. Codeforces Round #521 (Div.3)题解

    A过水,不讲 题解 CF1077B [Disturbed People] 这题就是个显而易见的贪心可是我考场上差点没想出来 显然把一户被打扰的人家的右边人家的灯关掉肯定比把左边的灯关掉 从左到右扫一遍 ...

  8. Codeforces Round #521 (Div. 3)

    B 题过的有些牵强,浪费了很多时间,这种题一定想好思路和边界条件再打,争取一发过.  D 题最开始读错题,后面最后发现可以重复感觉就没法做了,现在想来,数据量大,但是数据范围小枚举不行,二分还是可以的 ...

  9. Codeforces Round #521 Div. 3 玩耍记

    A:签到. #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> ...

随机推荐

  1. Codeforces Round #327 (Div. 2) C Median Smoothing(找规律)

    分析: 三个01组合只有八种情况: 000 s001 s010 0011 s100 s101 1110 s111 s 可以看出只有010,101是不稳定的.其他都是稳定的,且连续地出现了1或0,标记为 ...

  2. Handling Exceptions

    https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Exceptions/Tasks/Handling ...

  3. 【转载】2018 hosts 持续更新访问 gu歌【更新于:2018-05-03】

      修改HOSTS实现免费,简单访问谷歌的目的   也是比较稳定的方法.修改hosts.修改hosts的方法,原理在于直接存储谷歌网站的IP地址.这样就不用DNS来解析网址了.也就是说,当我们输入谷歌 ...

  4. c++连接mysql并提示“无法解析的外部符号 _mysql_server_init@12”解决方法&提示缺少“libmysql.dll”

    课程作业要用c++连接mysql server,但是出现些小问题,经查阅资料已经解决,做一下笔记. 环境:vs2017, mysql版本是8.0.16-winx64. 设置项目属性   项目 -  C ...

  5. 树莓派(raspberry pi)更改键盘布局

    http://blog.csdn.net/c80486/article/details/8460271 树莓派(raspberry pi)用了几次后,发现键盘老是按错,一些字符打不出来或打错 这个问题 ...

  6. java基础编程—统计二进制数中1的个数

    题目描述 输入一个整数,输出该数二进制表示中1的个数.其中负数用补码表示. 题目代码 /** * 输入一个整数,输出该数二进制表示中1的个数.其中负数用补码表示. * Created by YuKai ...

  7. JQuery从服务器端取得数据绑定到dropdownlist(select)中

    http://blog.csdn.net/gaofang2009/article/details/5840783 http://www.cnblogs.com/Mac_Hui/archive/2010 ...

  8. 关于Star UML

    为什么是使用Star UML而不是Visio 2013呢? 以前本人在大学期间使用的Visio 2013来绘制UML的,最近一个星期因为在阅读源码,所以有多学了一门UML绘制工具—Star UML,下 ...

  9. iOS进阶面试题

    1. 风格纠错题 修改完的代码: 修改方法有很多种,现给出一种做示例: // .h文件 // http://weibo.com/luohanchenyilong/ // https://github. ...

  10. PHP 计算代码运行所占内存和时间

    PHP 计算代码运行所占内存和时间 在PHP开发过程中,写出高质量的代码是很重要的,除了代码必须规范之外,性能也是不可忽视的一方面,那么如果检验一段代码是否高效呢,可通过以下一段php代码来粗略检测 ...