結果

問題 No.884 Eat and Add
ユーザー hedwig100hedwig100
提出日時 2020-04-16 15:59:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 80 ms / 1,000 ms
コード長 924 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 14,080 KB
最終ジャッジ日時 2024-04-09 19:14:21
合計ジャッジ時間 1,707 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,624 KB
testcase_01 AC 29 ms
10,624 KB
testcase_02 AC 27 ms
10,624 KB
testcase_03 AC 72 ms
13,952 KB
testcase_04 AC 73 ms
14,080 KB
testcase_05 AC 70 ms
13,952 KB
testcase_06 AC 75 ms
13,952 KB
testcase_07 AC 52 ms
13,952 KB
testcase_08 AC 74 ms
13,952 KB
testcase_09 AC 80 ms
13,952 KB
testcase_10 AC 28 ms
10,752 KB
testcase_11 AC 27 ms
10,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

INF = 10 ** 20
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from  heapq import heappop,heapify,heappush
from bisect import bisect_left

def main():
    n = list(input()) + ['0','0']

    ans = 0
    cnt_0 = 0
    flag = False
    cnt_1 = 0
    for i in range(len(n) - 2):
        if n[i] == '1':
            cnt_1 += 1
        if n[i] == '1' and n[i + 1] == '0' and n[i + 2] == '0':
            if cnt_1 > 1:
                flag = True
            if flag:
                ans += cnt_0 + 2
                cnt_0 = 0
                cnt_1 = 0
                flag = False
            else:
                ans += cnt_0 + 1
                cnt_0 = 0
                cnt_1 = 0
        if n[i] == '1' and n[i + 1] == '0' and n[i + 2] == '1':
            cnt_0 += 1
            if cnt_1 > 1:
                flag = True
            cnt_1 = 0

    print(ans)

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