結果

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

ソースコード

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+1)
            zc = 0
            oc = 0
        else:
            zc += 1
    #print(oc,zc,i)

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