結果

問題 No.884 Eat and Add
ユーザー stngstng
提出日時 2022-08-07 17:46:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 69 ms / 1,000 ms
コード長 457 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 81,668 KB
実行使用メモリ 84,384 KB
最終ジャッジ日時 2023-10-17 12:31:46
合計ジャッジ時間 1,646 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,416 KB
testcase_01 AC 38 ms
53,416 KB
testcase_02 AC 38 ms
53,416 KB
testcase_03 AC 67 ms
82,328 KB
testcase_04 AC 68 ms
84,384 KB
testcase_05 AC 67 ms
84,384 KB
testcase_06 AC 69 ms
84,384 KB
testcase_07 AC 60 ms
82,108 KB
testcase_08 AC 63 ms
82,188 KB
testcase_09 AC 68 ms
82,328 KB
testcase_10 AC 37 ms
53,416 KB
testcase_11 AC 38 ms
53,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = '0'+input()
N = []
for i in range(len(n)):
    N.append(n[len(n)-1-i])
n = N
#print(n)
#exit()
ans = 0
ln = len(n)
oc = 0
zc = 0
for i in range(ln):
    if n[i] == "1":
        if i == ln-1:
            ans += 1
        elif n[i+1] == "0":
            ans += 1
            n[i] = "0"
        else:
            while n[i] == "1":
                n[i] = "0"
                i += 1
            n[i] = "1"
            #i -= 1
            ans += 1
print(ans)
0