結果

問題 No.910 素数部分列
ユーザー brthyyjp
提出日時 2022-02-10 17:07:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 83 ms / 1,000 ms
コード長 360 bytes
コンパイル時間 907 ms
コンパイル使用メモリ 82,344 KB
実行使用メモリ 84,608 KB
最終ジャッジ日時 2024-06-25 23:40:37
合計ジャッジ時間 4,841 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = list(str(input()))

ans = 0
cnt1 = 0
cnt9 = 0
for c in s:
    if c == '3' or c == '5' or c == '7':
        ans += 1
    elif c == '9':
        if cnt1:
            cnt1 -= 1
            ans += 1
        else:
            cnt9 += 1
    else:
        cnt1 += 1

q = cnt9//2
ans += min(q, cnt1)
cnt1 -= min(q, cnt1)
ans += cnt1//2
print(ans)
0