結果

問題 No.910 素数部分列
ユーザー lam6er
提出日時 2025-04-15 21:33:06
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 500 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 82,120 KB
実行使用メモリ 76,152 KB
最終ジャッジ日時 2025-04-15 21:35:23
合計ジャッジ時間 4,000 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 WA * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = input()

from collections import defaultdict

count = defaultdict(int)
for c in s:
    count[c] += 1

ans = 0

# Step 1: Count 1-digit primes (3, 5, 7)
ans += count['3'] + count['5'] + count['7']
count['3'] = 0
count['5'] = 0
count['7'] = 0

# Step 2: Form as many 11 as possible
x = count['1']
ans += x // 2
remaining_ones = x % 2
count['1'] = remaining_ones

# Step 3: Form primes with 1 and 9 (19)
possible_pairs = min(count['1'], count['9'])
ans += possible_pairs

print(ans)
0