結果

問題 No.910 素数部分列
ユーザー Chihaya_chan
提出日時 2020-06-14 00:37:52
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 562 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 12,788 KB
最終ジャッジ日時 2024-06-26 03:03:03
合計ジャッジ時間 8,143 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

# problem 1
N = int(input())
S = list(input())
ans = 0
dic = {"1": 0, "3": 0, "5": 0, "7": 0, "9": 0}
for some in S:
    dic[some] += 1

ans = dic["3"]+dic["5"]+dic["7"]
new = {1: 0, 9: 0}
for x in S:
    n = int(x)
    if n == 1: new[1] += 1
    if n == 9:
        new[9] += 1
        if new[1] > 0:
            new[1] -= 1
            new[9] -= 1
            ans += 1

if new[9] >= new[1]**2:
    ans += new[1]
    print(ans)
    exit()
    
elif new[9] < new[1]**2:
    p = new[9]//2
    ans += p
    new[1] -= p
    ans += new[1]//2
    print(ans)
    exit()
0