結果
| 問題 | No.910 素数部分列 |
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-02-27 13:14:00 |
| 言語 | Python3 (3.15.2 + numpy 2.5.4 + scipy 1.18.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 57 ms / 1,000 ms |
| + 893µs | |
| コード長 | 533 bytes |
| 記録 | |
| コンパイル時間 | 54 ms |
| コンパイル使用メモリ | 14,720 KB |
| 実行使用メモリ | 12,388 KB |
| 最終ジャッジ日時 | 2026-11-15 15:48:16 |
| 合計ジャッジ時間 | 4,715 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 52 |
ソースコード
#!/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)
# %%
T = [0]
for x in map(int, S):
if x == 9 and T[-1] == 1:
answer += 1
T.pop()
else:
T.append(x)
x9 = T.count(9)
x1 = T.count(1)
n = min(x9 // 2, x1)
answer += n
x1 -= n
answer += x1 // 2
print(answer)
maspy