結果

問題 No.910 素数部分列
ユーザー Chihaya_chanChihaya_chan
提出日時 2020-06-14 00:44:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 182 ms / 1,000 ms
コード長 694 bytes
コンパイル時間 117 ms
コンパイル使用メモリ 10,964 KB
実行使用メモリ 10,052 KB
最終ジャッジ日時 2023-09-08 10:12:00
合計ジャッジ時間 7,176 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,184 KB
testcase_01 AC 16 ms
8,328 KB
testcase_02 AC 17 ms
8,276 KB
testcase_03 AC 16 ms
8,152 KB
testcase_04 AC 16 ms
8,208 KB
testcase_05 AC 15 ms
8,296 KB
testcase_06 AC 16 ms
8,160 KB
testcase_07 AC 16 ms
8,148 KB
testcase_08 AC 16 ms
8,276 KB
testcase_09 AC 16 ms
8,268 KB
testcase_10 AC 15 ms
8,208 KB
testcase_11 AC 15 ms
8,196 KB
testcase_12 AC 15 ms
8,152 KB
testcase_13 AC 16 ms
8,332 KB
testcase_14 AC 15 ms
8,328 KB
testcase_15 AC 16 ms
8,204 KB
testcase_16 AC 15 ms
8,208 KB
testcase_17 AC 15 ms
8,132 KB
testcase_18 AC 16 ms
8,304 KB
testcase_19 AC 15 ms
8,208 KB
testcase_20 AC 15 ms
8,208 KB
testcase_21 AC 15 ms
8,152 KB
testcase_22 AC 15 ms
8,280 KB
testcase_23 AC 140 ms
9,884 KB
testcase_24 AC 138 ms
9,912 KB
testcase_25 AC 135 ms
9,956 KB
testcase_26 AC 137 ms
9,868 KB
testcase_27 AC 136 ms
9,916 KB
testcase_28 AC 136 ms
9,900 KB
testcase_29 AC 177 ms
9,872 KB
testcase_30 AC 179 ms
9,848 KB
testcase_31 AC 175 ms
9,796 KB
testcase_32 AC 179 ms
9,932 KB
testcase_33 AC 180 ms
9,960 KB
testcase_34 AC 180 ms
9,972 KB
testcase_35 AC 182 ms
9,896 KB
testcase_36 AC 177 ms
9,976 KB
testcase_37 AC 176 ms
9,972 KB
testcase_38 AC 179 ms
9,932 KB
testcase_39 AC 176 ms
9,968 KB
testcase_40 AC 175 ms
9,880 KB
testcase_41 AC 173 ms
9,904 KB
testcase_42 AC 169 ms
9,968 KB
testcase_43 AC 173 ms
9,904 KB
testcase_44 AC 171 ms
9,828 KB
testcase_45 AC 175 ms
9,968 KB
testcase_46 AC 173 ms
9,876 KB
testcase_47 AC 174 ms
9,964 KB
testcase_48 AC 152 ms
9,900 KB
testcase_49 AC 131 ms
9,852 KB
testcase_50 AC 132 ms
9,852 KB
testcase_51 AC 114 ms
9,848 KB
testcase_52 AC 167 ms
10,052 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[9]>0 and 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:

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