結果

問題 No.910 素数部分列
ユーザー OKCH3COOH
提出日時 2019-10-26 21:50:53
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 118 ms / 1,000 ms
コード長 439 bytes
コンパイル時間 529 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 12,800 KB
最終ジャッジ日時 2024-09-14 18:43:57
合計ジャッジ時間 5,892 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter

N = int(input())
S = input()

A = []
ans = 0

# 11, 19, 991

for s in S:
    if s == '3' or s == '5' or s == '7':
        ans += 1
    else:
        A.append(s)

one = 0
nine = 0
for s in A:
    if s == '1':
        one += 1
    else:
        if one > 0:
            ans += 1
            one -= 1
        else:
            nine += 1

add = min(nine // 2, one)
ans += add
ans += (one - add) // 2

print(ans)
0