結果

問題 No.884 Eat and Add
ユーザー stng
提出日時 2022-08-07 16:18:38
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 394 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 82,252 KB
実行使用メモリ 61,876 KB
最終ジャッジ日時 2024-09-17 09:34:06
合計ジャッジ時間 1,349 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
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(i,ans,zc,oc)
#print(oc,zc)
#print(ans)
if n[0] == "0":
    ans += min(oc,zc+1)
else:
    ans += min(oc,zc+2)
print(ans)
0