結果

問題 No.884 Eat and Add
ユーザー kohei2019kohei2019
提出日時 2022-05-06 12:15:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 132 ms / 1,000 ms
コード長 412 bytes
コンパイル時間 837 ms
コンパイル使用メモリ 87,080 KB
実行使用メモリ 93,360 KB
最終ジャッジ日時 2023-09-19 01:21:51
合計ジャッジ時間 3,391 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,400 KB
testcase_01 AC 73 ms
71,456 KB
testcase_02 AC 73 ms
71,268 KB
testcase_03 AC 132 ms
93,272 KB
testcase_04 AC 101 ms
93,360 KB
testcase_05 AC 101 ms
93,356 KB
testcase_06 AC 100 ms
93,320 KB
testcase_07 AC 96 ms
93,328 KB
testcase_08 AC 95 ms
93,136 KB
testcase_09 AC 98 ms
93,244 KB
testcase_10 AC 74 ms
71,088 KB
testcase_11 AC 73 ms
71,208 KB
権限があれば一括ダウンロードができます

ソースコード

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