結果

問題 No.3015 右に寄せろ!
コンテスト
ユーザー yamasaKit_
提出日時 2025-01-27 22:44:52
言語 Python3
(3.15.2 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 770 ms / 2,000 ms
+ 742µs
コード長 765 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 636 ms
コンパイル使用メモリ 14,464 KB
実行使用メモリ 110,904 KB
最終ジャッジ日時 2026-11-15 19:57:06
合計ジャッジ時間 9,921 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import *
from itertools import *
from functools import cache, partial
from pprint import pprint
import sys
from typing import Any, Final

try:
    from icecream import ic
except ImportError:  # Graceful fallback if IceCream isn't installed.
    ic = lambda *a: None if not a else (a[0] if len(a) == 1 else a)  # noqa
debug = partial(print, file=sys.stderr)
dpprint = partial(pprint, stream=sys.stderr)
sys.setrecursionlimit(10**6)
MOD = 998244353

S = list(input())

T = []
for i, s in enumerate(S):
    if s == "0":
        T.append(i)
# ic(S)
# ic(T)

ans = 0
U = []
for t in T:
    # ic(U, t)
    if len(U) == 0:
        r = 0
    else:
        r = U[-1] + 1

    cnt = (t - r) // 2
    ans += cnt
    U.append(t - 2 * cnt)

# ic(U)

print(ans)
0