結果

問題 No.884 Eat and Add
ユーザー ああいいああいい
提出日時 2022-01-01 22:06:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 65 ms / 1,000 ms
コード長 410 bytes
コンパイル時間 434 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 73,984 KB
最終ジャッジ日時 2024-04-18 22:16:34
合計ジャッジ時間 1,665 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
51,584 KB
testcase_01 AC 40 ms
51,712 KB
testcase_02 AC 40 ms
51,584 KB
testcase_03 AC 64 ms
72,832 KB
testcase_04 AC 61 ms
73,728 KB
testcase_05 AC 65 ms
72,448 KB
testcase_06 AC 64 ms
73,984 KB
testcase_07 AC 52 ms
69,888 KB
testcase_08 AC 49 ms
69,376 KB
testcase_09 AC 59 ms
70,400 KB
testcase_10 AC 39 ms
52,224 KB
testcase_11 AC 40 ms
52,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = list(input())
N = N[::-1]
ans = 0

i = 0
while i < len(N):
    if N[i] == "1":
        j = i
        while j < len(N) and N[j] == "1":
            j += 1
        ans += 1
        if j - i== 1:
            i = j + 1
        else:
            if j == len(N):
                ans += 1
                break
            else:
                N[j] = "1"
                i = j
    else:
        i += 1
print(ans)
0