結果

問題 No.910 素数部分列
ユーザー nep_pudding3
提出日時 2019-10-18 23:37:46
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 119 ms / 1,000 ms
コード長 337 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-06-25 22:01:14
合計ジャッジ時間 5,354 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = input()
ans = 0
nine = 0
one = 0
for i in range(N):
    c = S[i]
    if c in '357':
        ans += 1
    if c == '9':
        if one >= 1:
            one -= 1
            ans += 1
        else:
            nine += 1
    if c == '1':
        one += 1
nno = min(nine//2,one) 
ans += nno+(one-nno)//2
print(ans)

    
0