結果

問題 No.910 素数部分列
ユーザー maspy
提出日時 2020-02-27 12:52:35
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 555 bytes
コンパイル時間 74 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 12,384 KB
最終ジャッジ日時 2024-10-13 15:51:53
合計ジャッジ時間 6,141 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 WA * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


# %%
N = int(readline())
S = read().rstrip().decode()

# %%
S = S.replace('3', '')
S = S.replace('5', '')
S = S.replace('7', '')

answer = N - len(S)

# %%
stack = [0]
for x in map(int, S):
    if stack[-1] == 1:
        answer += 1
        stack.pop()
    elif stack[-2:] == [9, 9] and x == 1:
        answer += 1
        stack.pop()
        stack.pop()
    else:
        stack.append(x)

# %%
print(answer)
0