Switch | 프로그래밍의 벗 PivotOJ
PivotOJ

Switch

시간 제한: 2000ms메모리 제한: 512MB출처: CCC 2011 SeniorBOJ 6787

문제

You are walking by a row of K (4 ≤ K ≤ 25) lights, some of which are on and some of which are off. In this initial configuration, there is no consecutive sequence of four lights that are on.

Whenever four or more consecutive lights are on, the lights in that consecutive block will turn off.

You can only turn on lights that are off.

What is the minimum number of lights you need to turn on in order to end up with all K lights off?

입력

The first line of input will consist of the integer K, indicating the number of lights. Each of the next K lines will have either the integer 0 (to represent a light that is off) or the integer 1 (to represent a light that is on).

출력

Your program should output the minimum number of lights that must be turned on in order to have all K lights be off.

예제

예제 1

입력
5
1
1
0
1
1
출력
1
코드를 제출하려면 로그인하세요.