Logo
(追記) (追記ここまで)

6787번 - Switch 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB94222238.596%

문제

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

1

Notice that turning on the third light will create five consecutive lights that are on, which will in turn cause all of these five lights to be off.

힌트

출처

Olympiad > Canadian Computing Competition & Olympiad > 2011 > CCC 2011 Senior Division 5번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /