結果
問題 | No.884 Eat and Add |
ユーザー |
![]() |
提出日時 | 2019-09-13 21:48:42 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 151 ms / 1,000 ms |
コード長 | 911 bytes |
コンパイル時間 | 79 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,904 KB |
最終ジャッジ日時 | 2024-07-04 04:06:39 |
合計ジャッジ時間 | 1,784 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 |
ソースコード
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)