結果

問題 No.910 素数部分列
ユーザー OKCH3COOHOKCH3COOH
提出日時 2019-10-26 21:50:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 92 ms / 1,000 ms
コード長 439 bytes
コンパイル時間 846 ms
コンパイル使用メモリ 10,692 KB
実行使用メモリ 10,608 KB
最終ジャッジ日時 2023-10-12 20:22:57
合計ジャッジ時間 5,615 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,584 KB
testcase_01 AC 18 ms
8,520 KB
testcase_02 AC 18 ms
8,560 KB
testcase_03 AC 17 ms
8,548 KB
testcase_04 AC 17 ms
8,520 KB
testcase_05 AC 17 ms
8,464 KB
testcase_06 AC 18 ms
8,452 KB
testcase_07 AC 17 ms
8,572 KB
testcase_08 AC 17 ms
8,588 KB
testcase_09 AC 17 ms
8,504 KB
testcase_10 AC 18 ms
8,504 KB
testcase_11 AC 17 ms
8,556 KB
testcase_12 AC 17 ms
8,496 KB
testcase_13 AC 18 ms
8,464 KB
testcase_14 AC 17 ms
8,576 KB
testcase_15 AC 17 ms
8,572 KB
testcase_16 AC 18 ms
8,556 KB
testcase_17 AC 18 ms
8,588 KB
testcase_18 AC 18 ms
8,504 KB
testcase_19 AC 18 ms
8,560 KB
testcase_20 AC 18 ms
8,504 KB
testcase_21 AC 18 ms
8,516 KB
testcase_22 AC 18 ms
8,504 KB
testcase_23 AC 66 ms
9,332 KB
testcase_24 AC 69 ms
9,788 KB
testcase_25 AC 66 ms
9,848 KB
testcase_26 AC 67 ms
9,808 KB
testcase_27 AC 65 ms
9,336 KB
testcase_28 AC 69 ms
9,424 KB
testcase_29 AC 87 ms
10,608 KB
testcase_30 AC 92 ms
10,524 KB
testcase_31 AC 88 ms
10,160 KB
testcase_32 AC 92 ms
10,360 KB
testcase_33 AC 92 ms
10,464 KB
testcase_34 AC 91 ms
10,356 KB
testcase_35 AC 89 ms
10,352 KB
testcase_36 AC 90 ms
10,424 KB
testcase_37 AC 90 ms
10,428 KB
testcase_38 AC 91 ms
10,356 KB
testcase_39 AC 91 ms
10,368 KB
testcase_40 AC 92 ms
10,420 KB
testcase_41 AC 91 ms
10,412 KB
testcase_42 AC 88 ms
10,400 KB
testcase_43 AC 90 ms
10,532 KB
testcase_44 AC 88 ms
10,436 KB
testcase_45 AC 89 ms
10,368 KB
testcase_46 AC 90 ms
10,436 KB
testcase_47 AC 89 ms
10,408 KB
testcase_48 AC 85 ms
10,424 KB
testcase_49 AC 79 ms
10,428 KB
testcase_50 AC 80 ms
10,352 KB
testcase_51 AC 43 ms
8,832 KB
testcase_52 AC 91 ms
10,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter

N = int(input())
S = input()

A = []
ans = 0

# 11, 19, 991

for s in S:
    if s == '3' or s == '5' or s == '7':
        ans += 1
    else:
        A.append(s)

one = 0
nine = 0
for s in A:
    if s == '1':
        one += 1
    else:
        if one > 0:
            ans += 1
            one -= 1
        else:
            nine += 1

add = min(nine // 2, one)
ans += add
ans += (one - add) // 2

print(ans)
0