結果

問題 No.3114 0→1
ユーザー miya145592
提出日時 2025-04-19 18:14:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 269 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 81,788 KB
実行使用メモリ 73,920 KB
最終ジャッジ日時 2025-04-19 18:14:52
合計ジャッジ時間 3,394 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N = int(input())
S = input().strip()
ans = 0
cnt = N
for i in range(N):
    s = S[i]
    if s=="0":
        if cnt<2:
            ans += 1
            cnt += 1
        else:
            cnt = 0
    else:
        cnt += 1
print(ans)
0