結果

問題 No.3114 0→1
ユーザー ぽん🍊
提出日時 2025-04-20 00:05:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 385 bytes
コンパイル時間 360 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 71,056 KB
最終ジャッジ日時 2025-04-20 00:05:17
合計ジャッジ時間 3,433 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = [v for v in input()]

ans = 0
for i in range(n):
    if s[i] == "1":
        continue
    
    if i - 1 >= 0:
        if s[i - 1] == "0":
            s[i] = "1"
            ans += 1
            continue
        
    if i - 2 >= 0:
        if s[i - 2] == "0" and s[i - 1] == "1":
            s[i] = "1"
            ans += 1
            continue
        
print(ans)
0