結果

問題 No.884 Eat and Add
ユーザー kohei2019
提出日時 2022-05-06 12:15:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 67 ms / 1,000 ms
コード長 412 bytes
コンパイル時間 210 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 85,760 KB
最終ジャッジ日時 2024-07-05 14:14:29
合計ジャッジ時間 1,981 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

N = list(map(int,list(input())))
N.reverse()
NN = len(N)
ans = 0
cnt = 0
for i in range(NN):
    if N[i] == 1:
        cnt += 1
    else:
        if cnt == 0:
            continue
        elif cnt == 1:
            cnt = 0
            ans += 1
        else:
            cnt = 1
            ans += 1

if cnt == 0:
    pass
elif cnt == 1:
    cnt = 0
    ans += 1
else:
    cnt = 1
    ans += 2
print(ans)
        
0