結果

問題 No.884 Eat and Add
ユーザー 👑 tamatotamato
提出日時 2020-04-29 22:31:34
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 91 ms / 1,000 ms
コード長 648 bytes
コンパイル時間 604 ms
コンパイル使用メモリ 87,640 KB
実行使用メモリ 82,048 KB
最終ジャッジ日時 2023-08-20 03:35:33
合計ジャッジ時間 2,887 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,880 KB
testcase_01 AC 70 ms
71,724 KB
testcase_02 AC 72 ms
71,532 KB
testcase_03 AC 90 ms
82,048 KB
testcase_04 AC 90 ms
81,948 KB
testcase_05 AC 90 ms
81,812 KB
testcase_06 AC 91 ms
81,684 KB
testcase_07 AC 85 ms
81,760 KB
testcase_08 AC 86 ms
81,668 KB
testcase_09 AC 90 ms
81,800 KB
testcase_10 AC 73 ms
71,648 KB
testcase_11 AC 72 ms
71,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    S = input().rstrip('\n')
    A = [int(s) for s in S[::-1]] + [0]
    N = len(A)

    ans = 0
    for i in range(N-1):
        if A[i]:
            if not A[i+1]:
                ans += 1
            else:
                ans += 1
                j = i
                while True:
                    if A[j] == 1:
                        A[j] = 0
                        j += 1
                    else:
                        A[j] = 1
                        break
    if A[-1]:
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()
0