結果

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

ソースコード

diff #

n = int(input())
s =list(input().rstrip())
ans = 0
for i in range(n):
    if i-2 >= 0 and s[i-2] == '0' and s[i-1] == '1' and s[i] == '0':
        s[i] = '1'
        ans += 1
    if i-1 >= 0 and s[i-1] == s[i] == '0':
        s[i] = '1'
        ans += 1
print(ans)
0