結果

問題 No.910 素数部分列
ユーザー kurimupykurimupy
提出日時 2020-06-18 01:49:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 123 ms / 1,000 ms
コード長 694 bytes
コンパイル時間 407 ms
コンパイル使用メモリ 87,032 KB
実行使用メモリ 86,176 KB
最終ジャッジ日時 2023-09-16 11:52:45
合計ジャッジ時間 7,764 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
70,872 KB
testcase_01 AC 74 ms
71,020 KB
testcase_02 AC 74 ms
71,024 KB
testcase_03 AC 75 ms
70,904 KB
testcase_04 AC 76 ms
70,956 KB
testcase_05 AC 76 ms
71,160 KB
testcase_06 AC 74 ms
71,124 KB
testcase_07 AC 75 ms
71,104 KB
testcase_08 AC 75 ms
70,932 KB
testcase_09 AC 76 ms
71,060 KB
testcase_10 AC 73 ms
70,896 KB
testcase_11 AC 77 ms
70,904 KB
testcase_12 AC 76 ms
71,012 KB
testcase_13 AC 77 ms
71,128 KB
testcase_14 AC 72 ms
70,928 KB
testcase_15 AC 73 ms
70,956 KB
testcase_16 AC 72 ms
71,040 KB
testcase_17 AC 71 ms
71,012 KB
testcase_18 AC 72 ms
71,092 KB
testcase_19 AC 72 ms
70,952 KB
testcase_20 AC 70 ms
70,904 KB
testcase_21 AC 70 ms
71,168 KB
testcase_22 AC 70 ms
71,008 KB
testcase_23 AC 107 ms
84,792 KB
testcase_24 AC 111 ms
85,148 KB
testcase_25 AC 110 ms
84,848 KB
testcase_26 AC 109 ms
84,920 KB
testcase_27 AC 111 ms
85,124 KB
testcase_28 AC 114 ms
85,184 KB
testcase_29 AC 115 ms
85,352 KB
testcase_30 AC 117 ms
85,588 KB
testcase_31 AC 112 ms
84,912 KB
testcase_32 AC 115 ms
85,192 KB
testcase_33 AC 116 ms
85,260 KB
testcase_34 AC 116 ms
85,484 KB
testcase_35 AC 114 ms
85,396 KB
testcase_36 AC 123 ms
85,504 KB
testcase_37 AC 115 ms
85,488 KB
testcase_38 AC 117 ms
85,492 KB
testcase_39 AC 113 ms
85,224 KB
testcase_40 AC 115 ms
85,292 KB
testcase_41 AC 114 ms
85,508 KB
testcase_42 AC 117 ms
85,484 KB
testcase_43 AC 116 ms
85,560 KB
testcase_44 AC 117 ms
85,596 KB
testcase_45 AC 118 ms
85,596 KB
testcase_46 AC 118 ms
85,392 KB
testcase_47 AC 118 ms
85,504 KB
testcase_48 AC 112 ms
86,176 KB
testcase_49 AC 95 ms
79,356 KB
testcase_50 AC 106 ms
85,480 KB
testcase_51 AC 94 ms
79,520 KB
testcase_52 AC 112 ms
85,696 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