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

34800번 - Server Corridor 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB41301965.517%

문제

Audrey is system administrator for miHoYo! It is her job to manage the server room and keep her favorite video game, Honkai: Star Rail, up and running.

The miHoYo server room is broken up into a single corridor of sections, some of which have servers installed. Some of the servers are already turned on.

Audrey urgently needs to turn on more servers. However, the server room has bad ventilation, so if two servers in adjacent sections are both on, then the room will overheat.

Audrey cannot turn off servers that are already on. Compute the maximum number of servers Audrey can turn on from the ones that are currently off without causing the room to overheat.

입력

The first line of input contains a single integer, $n$ (1ドル \le n \le 3 \cdot 10^5$).

The second line of input contains a ternary string $s$ of length $n,ドル representing the room. A character of 0 represents a section with no server, a character of 1 represents a section with a server that is off, and a character of 2 represents a section with a server that is on.

It is guaranteed that the server room is not currently overheating.

출력

Output a single number, the number of additional servers Audrey can turn on from the ones that are currently off.

제한

예제 입력 1

7
1112111

예제 출력 1

2

예제 입력 2

3
212

예제 출력 2

0

예제 입력 3

3
101

예제 출력 3

2

노트

출처

ICPC > Regionals > North America > Pacific Northwest Regional > 2025 ICPC Pacific Northwest Regional > Division 2 I번

  • 문제를 만든 사람: Nick Wu
(追記) (追記ここまで)

출처

대학교 대회

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

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