結果

問題 No.910 素数部分列
ユーザー kohei2019kohei2019
提出日時 2022-08-03 02:17:31
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 849 bytes
コンパイル時間 1,414 ms
コンパイル使用メモリ 86,980 KB
実行使用メモリ 134,420 KB
最終ジャッジ日時 2023-10-01 02:54:36
合計ジャッジ時間 9,634 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,100 KB
testcase_01 AC 73 ms
71,284 KB
testcase_02 AC 73 ms
71,088 KB
testcase_03 AC 73 ms
71,088 KB
testcase_04 AC 72 ms
71,420 KB
testcase_05 AC 71 ms
71,444 KB
testcase_06 AC 71 ms
71,000 KB
testcase_07 AC 71 ms
71,272 KB
testcase_08 AC 70 ms
71,004 KB
testcase_09 AC 71 ms
71,004 KB
testcase_10 WA -
testcase_11 AC 72 ms
71,408 KB
testcase_12 AC 72 ms
71,348 KB
testcase_13 AC 70 ms
71,380 KB
testcase_14 WA -
testcase_15 AC 71 ms
71,284 KB
testcase_16 AC 73 ms
71,392 KB
testcase_17 AC 72 ms
71,464 KB
testcase_18 AC 71 ms
71,276 KB
testcase_19 AC 71 ms
71,244 KB
testcase_20 AC 71 ms
71,468 KB
testcase_21 AC 72 ms
71,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 118 ms
98,096 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 128 ms
113,192 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 133 ms
112,656 KB
testcase_35 AC 130 ms
107,600 KB
testcase_36 AC 132 ms
107,600 KB
testcase_37 AC 131 ms
107,352 KB
testcase_38 AC 135 ms
107,500 KB
testcase_39 AC 133 ms
107,624 KB
testcase_40 AC 133 ms
110,852 KB
testcase_41 AC 138 ms
107,676 KB
testcase_42 AC 141 ms
107,520 KB
testcase_43 AC 134 ms
107,464 KB
testcase_44 AC 134 ms
107,388 KB
testcase_45 AC 133 ms
107,612 KB
testcase_46 AC 133 ms
107,700 KB
testcase_47 AC 129 ms
107,596 KB
testcase_48 AC 136 ms
134,420 KB
testcase_49 AC 137 ms
134,180 KB
testcase_50 AC 136 ms
134,260 KB
testcase_51 AC 95 ms
93,244 KB
testcase_52 AC 122 ms
113,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
lsS = list(map(int,list(input())))
cnt = 0
lsS1 = []
pS = set([3,5,7])
for i in range(N):
    if lsS[i] in pS:
        cnt += 1
    else:
        lsS1.append(lsS[i])
cn1 = 0
cn19 = 0
for s in lsS1:
    if s == 1:
        cn1 += 1
    else:
        if cn1 > 0:
            cnt += 1
            cn19 += 1
            cn1 -= 1
ls3 = []
cn19_ = cn19
for s in range(len(lsS1)-1,-1,-1):
    if cn19_>0 and (lsS1[s]==9):
        cn19_ -= 1
    else:
        ls3.append(lsS1[s])
ls3.reverse()
ls4 = []
cn19_ = cn19
for s in range(len(ls3)):
    if cn19_>0 and (ls3[s]==1):
        cn19_ -= 1
    else:
        ls4.append(ls3[s])
cn1 = 0
cn9 = 0
for i in range(len(ls4)):
    if ls4[i] == 9:
        cn9 += 1
    else:
        if cn9 >= 2:
            cnt += 1
            cn9 -= 1
        else:
            cn1 += 1
cnt += cn1//2
print(cnt)
0