結果

問題 No.3015 右に寄せろ!
ユーザー kmmtkm
提出日時 2025-01-25 13:33:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 325 ms / 2,000 ms
コード長 651 bytes
コンパイル時間 917 ms
コンパイル使用メモリ 82,852 KB
実行使用メモリ 276,564 KB
最終ジャッジ日時 2025-01-25 22:50:46
合計ジャッジ時間 5,492 ms
ジャッジサーバーID
(参考情報)
judge6 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque


# sys.setrecursionlimit(10**6)


def debug(*args):
    print(*args, file=sys.stderr)


s = deque(list(map(int, list(input()))))
# stack = []
stack_count = 0
ans = 0
while s:
    si = s.popleft()
    if si == 0:
        p = stack_count // 2
        ans += p
        stack_count = 2*p
        # next_stack = []
        # while len(stack) >= 2 and stack[-2] == stack[-1] == 1:
        #     ans += 1
        #     next_stack.append(stack.pop())
        #     next_stack.append(stack.pop())
        # stack, next_stack = next_stack, stack
    else:
        # stack.append(1)
        stack_count += 1

print(ans)
0