結果

問題 No.910 素数部分列
ユーザー Chihaya_chanChihaya_chan
提出日時 2020-06-14 00:36:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 564 bytes
コンパイル時間 706 ms
コンパイル使用メモリ 11,000 KB
実行使用メモリ 10,012 KB
最終ジャッジ日時 2023-09-08 09:56:48
合計ジャッジ時間 8,064 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,224 KB
testcase_01 AC 16 ms
8,216 KB
testcase_02 AC 15 ms
8,156 KB
testcase_03 AC 15 ms
8,224 KB
testcase_04 AC 15 ms
8,124 KB
testcase_05 AC 15 ms
8,104 KB
testcase_06 WA -
testcase_07 AC 16 ms
8,188 KB
testcase_08 AC 15 ms
8,248 KB
testcase_09 AC 15 ms
8,192 KB
testcase_10 AC 15 ms
8,164 KB
testcase_11 AC 15 ms
8,296 KB
testcase_12 AC 15 ms
8,244 KB
testcase_13 AC 15 ms
8,276 KB
testcase_14 AC 15 ms
8,284 KB
testcase_15 AC 15 ms
8,120 KB
testcase_16 AC 15 ms
8,260 KB
testcase_17 AC 16 ms
8,188 KB
testcase_18 AC 15 ms
8,160 KB
testcase_19 AC 16 ms
8,152 KB
testcase_20 AC 15 ms
8,132 KB
testcase_21 AC 15 ms
8,164 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 136 ms
9,748 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 175 ms
9,884 KB
testcase_36 WA -
testcase_37 AC 169 ms
9,912 KB
testcase_38 WA -
testcase_39 AC 169 ms
9,820 KB
testcase_40 WA -
testcase_41 AC 165 ms
9,936 KB
testcase_42 WA -
testcase_43 AC 165 ms
9,944 KB
testcase_44 AC 163 ms
9,936 KB
testcase_45 AC 169 ms
9,828 KB
testcase_46 AC 169 ms
9,964 KB
testcase_47 AC 167 ms
9,928 KB
testcase_48 AC 146 ms
9,884 KB
testcase_49 AC 131 ms
9,880 KB
testcase_50 AC 132 ms
9,876 KB
testcase_51 AC 109 ms
9,884 KB
testcase_52 AC 163 ms
9,824 KB
権限があれば一括ダウンロードができます

ソースコード

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*2
    ans += new[1]//2
    print(ans)
    exit()
0