結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,832 KB
testcase_01 AC 15 ms
7,948 KB
testcase_02 AC 16 ms
7,796 KB
testcase_03 AC 103 ms
10,928 KB
testcase_04 AC 103 ms
10,976 KB
testcase_05 AC 93 ms
11,016 KB
testcase_06 AC 108 ms
10,912 KB
testcase_07 AC 55 ms
10,876 KB
testcase_08 AC 85 ms
10,876 KB
testcase_09 AC 120 ms
10,992 KB
testcase_10 AC 16 ms
7,960 KB
testcase_11 AC 16 ms
7,792 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