結果
問題 |
No.910 素数部分列
|
ユーザー |
![]() |
提出日時 | 2025-06-12 21:19:31 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 773 bytes |
コンパイル時間 | 224 ms |
コンパイル使用メモリ | 82,076 KB |
実行使用メモリ | 96,124 KB |
最終ジャッジ日時 | 2025-06-12 21:19:58 |
合計ジャッジ時間 | 5,017 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 WA * 28 |
ソースコード
n = int(input()) s = input().strip() # Count single-digit primes (3,5,7) count3 = s.count('3') count5 = s.count('5') count7 = s.count('7') base = count3 + count5 + count7 # Build the remaining string after removing 3,5,7 remaining = [] for c in s: if c not in {'3', '5', '7'}: remaining.append(c) s_prime = ''.join(remaining) # Calculate additional operations for two-digit primes additional2 = 0 count9 = 0 # Traverse from right to left for c in reversed(s_prime): if c == '9': count9 += 1 elif c == '1': if count9 > 0: additional2 += 1 count9 -= 1 count1 = s_prime.count('1') count1_remaining = count1 - additional2 additional1 = count1_remaining // 2 total = base + additional2 + additional1 print(total)