結果

問題 No.884 Eat and Add
ユーザー stngstng
提出日時 2022-08-07 17:43:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 70 ms / 1,000 ms
コード長 487 bytes
コンパイル時間 1,231 ms
コンパイル使用メモリ 81,376 KB
実行使用メモリ 83,968 KB
最終ジャッジ日時 2023-10-17 12:29:46
合計ジャッジ時間 2,548 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,996 KB
testcase_01 AC 36 ms
52,996 KB
testcase_02 AC 37 ms
52,996 KB
testcase_03 AC 66 ms
81,904 KB
testcase_04 AC 70 ms
83,968 KB
testcase_05 AC 66 ms
83,968 KB
testcase_06 AC 67 ms
83,968 KB
testcase_07 AC 60 ms
81,692 KB
testcase_08 AC 63 ms
81,772 KB
testcase_09 AC 69 ms
81,916 KB
testcase_10 AC 38 ms
53,016 KB
testcase_11 AC 38 ms
53,016 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
                #print(i,n[i])
            n[i] = "1"
            i -= 1
            ans += 1
print(ans)
0