結果

問題 No.884 Eat and Add
ユーザー kawap23kawap23
提出日時 2019-09-13 22:58:04
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 124 ms / 1,000 ms
コード長 496 bytes
コンパイル時間 116 ms
コンパイル使用メモリ 10,560 KB
実行使用メモリ 11,068 KB
最終ジャッジ日時 2023-09-17 15:04:34
合計ジャッジ時間 1,632 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,916 KB
testcase_01 AC 16 ms
7,908 KB
testcase_02 AC 15 ms
7,860 KB
testcase_03 AC 105 ms
11,028 KB
testcase_04 AC 103 ms
10,980 KB
testcase_05 AC 91 ms
11,012 KB
testcase_06 AC 106 ms
10,872 KB
testcase_07 AC 56 ms
10,912 KB
testcase_08 AC 86 ms
11,068 KB
testcase_09 AC 124 ms
10,920 KB
testcase_10 AC 16 ms
7,840 KB
testcase_11 AC 16 ms
7,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = ['0'] + list(input())
# print (N)
tmp1= len(N) - 1
ans = 0
while tmp1 >= 1:
    if N[tmp1] == '0':
        tmp1 -= 1
    elif N[tmp1] == '1' and N[tmp1 - 1] == '1': 
        while N[tmp1 - 1] == '1':
            N[tmp1] = '0'
            N[tmp1 - 1] = '0'
            tmp1 -= 1
        N[tmp1 - 1] = '1'
        tmp1 -= 1
        ans += 1
    elif N[tmp1] == '1' and N[tmp1 - 1] == '0':
        ans += 1
        tmp1 -= 1
    # print (N)

if N[0] == '1':
    ans += 1
print (ans)

# print (N)
0