結果

問題 No.884 Eat and Add
ユーザー lloyz
提出日時 2022-09-05 21:38:28
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 162 ms / 1,000 ms
コード長 373 bytes
コンパイル時間 386 ms
コンパイル使用メモリ 12,288 KB
実行使用メモリ 14,252 KB
最終ジャッジ日時 2024-11-20 22:29:38
合計ジャッジ時間 1,903 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

L = list(map(int, list(input())))

L.reverse()
L.append(0)
n = len(L)
ans = 0
for i in range(n):
    if L[i] == 1:
        if i == n - 1:
            ans += 1
        elif L[i + 1] == 0:
            ans += 1
            L[i] = 0
        else:
            while L[i] == 1:
                L[i] = 0
                i += 1
            L[i] = 1
            ans += 1
print(ans)
0