結果
問題 |
No.910 素数部分列
|
ユーザー |
![]() |
提出日時 | 2025-04-15 21:28:38 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 460 bytes |
コンパイル時間 | 462 ms |
コンパイル使用メモリ | 82,480 KB |
実行使用メモリ | 109,036 KB |
最終ジャッジ日時 | 2025-04-15 21:31:40 |
合計ジャッジ時間 | 5,545 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 WA * 28 |
ソースコード
n = int(input()) s = input().strip() cnt1 = 0 remaining = [] for c in s: if c in {'3', '5', '7'}: cnt1 += 1 else: remaining.append(c) A = [i for i, c in enumerate(remaining) if c == '1'] B = [i for i, c in enumerate(remaining) if c == '9'] i = j = y = 0 while i < len(A) and j < len(B): if A[i] < B[j]: y += 1 i += 1 j += 1 else: j += 1 x = (len(A) - y) // 2 cnt2 = y + x print(cnt1 + cnt2)