結果

問題 No.884 Eat and Add
ユーザー stng
提出日時 2022-08-07 16:27:05
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 295 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 82,320 KB
実行使用メモリ 61,184 KB
最終ジャッジ日時 2024-09-17 09:41:56
合計ジャッジ時間 1,274 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

n = input()
ans = 0
ln = len(n)
oc = 0
zc = 0
for i in range(ln-1,-1,-1):
    if n[i] == "1":
        oc += 1
    else:
        if i != ln-1 and n[i+1] == "0":
            ans += min(oc,zc+2)
            zc = 0
            oc = 0
        else:
            zc += 1

ans += min(oc,zc+2)
print(ans)
0