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

20224번 - Count (削除) Down (削除ここまで) Up 2020 다국어

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

문제

The countdown to the Olympic and Paralympic Games Tokyo 2020 continues until summer 2021. That aside, you are asked to count up the occurrences of the four integers 2, 0, 2, and 0 appearing consecutively in this order in given lists of integers.

입력

The input consists of multiple datasets, each in the following format.

n d1dn

Each of the datasets consists of two lines. The first line has an integer n (4 ≤ n ≤ 1000), which is the number of integers listed in the second line. The second line contains n integers d1, …, dn separated by spaces. Here, all of d1 to dn are between 0 and 9, inclusive.

The end of the input is indicated by a line containing a zero.

The number of datasets does not exceed 100.

출력

For each of the datasets, output one line containing the number of times the four integers 2, 0, 2, and 0 appear consecutively in this order in the list of integers in its second line. Overlapping occurrences are separately counted. “2 0 2 0 2 0 2 0”, for example, is said to have three occurrences, rather than two.

제한

예제 입력 1

15
2 0 2 0 2 2 0 2 0 2 2 0 2 0 2
20
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
32
1 8 1 9 1 9 2 0 2 0 2 1 2 1 2 2 2 2 2 1 2 1 2 0 2 0 1 9 1 9 1 8
32
2 0 1 8 2 0 1 9 2 0 2 0 2 0 2 1 2 0 2 2 2 0 2 3 2 0 2 1 2 0 2 0
0

예제 출력 1

3
0
2
3

힌트

출처

ICPC > Regionals > Asia Pacific > Japan > Japan Domestic Contest > 2020 Japan Domestic Contest A번

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

출처

대학교 대회

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

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