結果

問題 No.884 Eat and Add
ユーザー convexineqconvexineq
提出日時 2020-11-01 09:13:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 129 ms / 1,000 ms
コード長 284 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 10,708 KB
実行使用メモリ 11,468 KB
最終ジャッジ日時 2023-09-29 11:07:27
合計ジャッジ時間 1,670 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,820 KB
testcase_01 AC 17 ms
7,796 KB
testcase_02 AC 16 ms
7,836 KB
testcase_03 AC 107 ms
11,304 KB
testcase_04 AC 107 ms
11,452 KB
testcase_05 AC 102 ms
11,468 KB
testcase_06 AC 107 ms
11,288 KB
testcase_07 AC 77 ms
11,424 KB
testcase_08 AC 72 ms
11,392 KB
testcase_09 AC 129 ms
11,292 KB
testcase_10 AC 16 ms
7,888 KB
testcase_11 AC 16 ms
7,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = [0] + [int(i) for i in input()]
ans = 0
while N:
    if N[-1]==0: N.pop()
    elif len(N)==1: ans += 1; N.pop()
    elif N[-1]==1 and N[-2]==0:
        ans += 1
        N.pop()
    else:
        ans += 1
        while N[-1]==1:
            N.pop()
        N[-1] = 1
print(ans)    
0