結果
問題 | No.910 素数部分列 |
ユーザー | Coki628 |
提出日時 | 2020-08-07 17:14:51 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 85 ms / 1,000 ms |
コード長 | 1,300 bytes |
コンパイル時間 | 314 ms |
コンパイル使用メモリ | 83,244 KB |
実行使用メモリ | 91,564 KB |
最終ジャッジ日時 | 2024-09-24 11:42:30 |
合計ジャッジ時間 | 5,213 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
54,552 KB |
testcase_01 | AC | 40 ms
54,644 KB |
testcase_02 | AC | 41 ms
56,252 KB |
testcase_03 | AC | 41 ms
54,880 KB |
testcase_04 | AC | 42 ms
54,844 KB |
testcase_05 | AC | 41 ms
56,200 KB |
testcase_06 | AC | 41 ms
55,988 KB |
testcase_07 | AC | 45 ms
55,184 KB |
testcase_08 | AC | 40 ms
54,776 KB |
testcase_09 | AC | 42 ms
54,268 KB |
testcase_10 | AC | 42 ms
54,776 KB |
testcase_11 | AC | 43 ms
55,012 KB |
testcase_12 | AC | 42 ms
54,924 KB |
testcase_13 | AC | 41 ms
54,308 KB |
testcase_14 | AC | 42 ms
54,260 KB |
testcase_15 | AC | 42 ms
54,456 KB |
testcase_16 | AC | 41 ms
54,920 KB |
testcase_17 | AC | 42 ms
54,260 KB |
testcase_18 | AC | 41 ms
55,056 KB |
testcase_19 | AC | 41 ms
54,684 KB |
testcase_20 | AC | 41 ms
54,660 KB |
testcase_21 | AC | 41 ms
55,060 KB |
testcase_22 | AC | 41 ms
54,256 KB |
testcase_23 | AC | 77 ms
78,244 KB |
testcase_24 | AC | 78 ms
78,048 KB |
testcase_25 | AC | 79 ms
78,196 KB |
testcase_26 | AC | 77 ms
78,532 KB |
testcase_27 | AC | 82 ms
78,184 KB |
testcase_28 | AC | 83 ms
78,140 KB |
testcase_29 | AC | 78 ms
78,248 KB |
testcase_30 | AC | 77 ms
78,544 KB |
testcase_31 | AC | 79 ms
78,048 KB |
testcase_32 | AC | 77 ms
78,524 KB |
testcase_33 | AC | 75 ms
78,336 KB |
testcase_34 | AC | 82 ms
78,144 KB |
testcase_35 | AC | 81 ms
78,200 KB |
testcase_36 | AC | 85 ms
78,428 KB |
testcase_37 | AC | 80 ms
78,332 KB |
testcase_38 | AC | 84 ms
78,248 KB |
testcase_39 | AC | 82 ms
78,444 KB |
testcase_40 | AC | 82 ms
78,428 KB |
testcase_41 | AC | 81 ms
78,404 KB |
testcase_42 | AC | 83 ms
78,212 KB |
testcase_43 | AC | 81 ms
78,316 KB |
testcase_44 | AC | 81 ms
78,372 KB |
testcase_45 | AC | 80 ms
78,492 KB |
testcase_46 | AC | 81 ms
78,248 KB |
testcase_47 | AC | 81 ms
78,332 KB |
testcase_48 | AC | 71 ms
77,992 KB |
testcase_49 | AC | 81 ms
91,500 KB |
testcase_50 | AC | 78 ms
91,564 KB |
testcase_51 | AC | 67 ms
78,360 KB |
testcase_52 | AC | 79 ms
85,152 KB |
ソースコード
import sys from collections import Counter def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)] def ceil(x, y=1): return int(-(-x // y)) def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)] def Yes(): print('Yes') def No(): print('No') def YES(): print('YES') def NO(): print('NO') sys.setrecursionlimit(10 ** 9) INF = 10 ** 19 MOD = 10 ** 9 + 7 EPS = 10 ** -10 N = INT() S = input() C = Counter(S) ans = C['3'] + C['5'] + C['7'] # 19 cnt1 = [] used = [0] * N for i in range(N): if S[i] == '9' and cnt1: j = cnt1.pop() ans += 1 used[i] = 1 used[j] = 1 C['1'] -= 1 elif S[i] == '1': cnt1.append(i) # 991 cnt9 = cnt99 = 0 for i in range(N): if used[i]: continue if S[i] == '1' and cnt99: cnt99 -= 1 ans += 1 C['1'] -= 1 elif S[i] == '9' and cnt9: cnt9 -= 1 cnt99 += 1 elif S[i] == '9': cnt9 += 1 # 11 ans += C['1'] // 2 print(ans)