結果

問題 No.884 Eat and Add
コンテスト
ユーザー simamumu
提出日時 2019-09-13 21:48:42
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 174 ms / 1,000 ms
+ 955µs
コード長 911 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 282 ms
コンパイル使用メモリ 21,540 KB
実行使用メモリ 16,124 KB
最終ジャッジ日時 2026-08-06 00:12:51
合計ジャッジ時間 3,309 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())


N = input() + '000'

ans = 0
tmp0 = 0
cnt0 = 0
cnt1 = 0
for sn in N:
    n = int(sn)
    #print(cnt0,cnt1,tmp0)
    if cnt0 == 0:
        if n == 1:
            cnt1 += 1
        else:
            tmp0 += 1
            cnt0 += 1
    elif cnt0 == 1:
        if n == 1:
            cnt0 = 0
            cnt1 += 1
        else:
            tmp0 += 1
            cnt0 += 1
    elif cnt0 == 2:
        ans += min(tmp0,cnt1)
        tmp0 = 0
        cnt0 += 1
        cnt1 = 0

    if cnt0 >= 3:
        if n == 1:
            cnt0 = 0
            cnt1 += 1

print(ans)
0