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. spa 小程序的研发随笔 (1) --- 前言

    半年前跳槽, 新公司主要研发倾向于小程序的开发.由于之前并没有接触小程序,所以经过半年的实际开发,才敢来做一点笔记. 小程序提供很多组件给开发者使用,但是,实际使用中还是会有很多的问题. 小程序的组件 ...

  2. [译文]详细解析如何做一款成功的APP应用

    译者注: 本文作者从自身丰富的应用开发设计实践经验和大量的优秀应用实例中,总结提炼了从产品概念.设计.开发到市场推广等一系列的相关原则,指导移动开发人员怎样来打造一款成功赚钱的应用.姗姗来迟的这篇文章 ...

  3. World Wind Java开发之三 显示状态栏信息(转)

    http://blog.csdn.net/giser_whu/article/details/40920315 先来看下本篇博客索要达到的效果: 找到源码下的gov.nasa.worldwind.ut ...

  4. 【51nod1705】七星剑(成环DP)

    点此看题面 大致题意: 你要把一把剑从0星升至7星,有n颗宝石供你选择,第i颗宝石的价值是c[i],用第i颗宝石将剑从k-1星升至k星的成功率是prob[k][i],而失败后会掉lose[k][i], ...

  5. python_65_生成器1

    # map()函数 # map()是 Python 内置的高阶函数,它接收一个函数 f 和一个 list,并通过把函数 f 依次作用在 list 的每个元素上,得到一个新的 list 并返回. # 例 ...

  6. IOS后台执行

    大多数应用程序进入后台状态不久后转入暂停状态.在这种状态下,应用程序不执行任何代码,并有可能在任意时候从内存中删除.应用程序提供特定的服务,用户可以请求后台执行时间,以提供这些服务. 判断是否支持多线 ...

  7. 第31题:LeetCode946. Validate Stack Sequences验证栈的序列

    题目 给定 pushed 和 popped 两个序列,只有当它们可能是在最初空栈上进行的推入 push 和弹出 pop 操作序列的结果时,返回 true:否则,返回 false . 示例 1: 输入: ...

  8. Dart Socket 与Java Socket连接

    -------------------------------------------------------------  Dart    SocketClient----------------- ...

  9. maven引入dubbo包后启动报错

    启动后报错内容为: Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exce ...

  10. 小象学院Python数据分析第二期【升级版】

    点击了解更多Python课程>>> 小象学院Python数据分析第二期[升级版] 主讲老师: 梁斌 资深算法工程师 查尔斯特大学(Charles Sturt University)计 ...