結果

問題 No.910 素数部分列
ユーザー stngstng
提出日時 2022-08-13 12:08:20
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,083 bytes
コンパイル時間 428 ms
コンパイル使用メモリ 81,544 KB
実行使用メモリ 133,368 KB
最終ジャッジ日時 2023-10-24 21:04:21
合計ジャッジ時間 7,166 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
55,364 KB
testcase_01 AC 42 ms
55,364 KB
testcase_02 AC 42 ms
55,364 KB
testcase_03 AC 44 ms
55,364 KB
testcase_04 AC 42 ms
55,364 KB
testcase_05 AC 42 ms
55,364 KB
testcase_06 AC 42 ms
55,364 KB
testcase_07 AC 42 ms
55,364 KB
testcase_08 AC 42 ms
55,364 KB
testcase_09 AC 42 ms
55,364 KB
testcase_10 AC 42 ms
55,364 KB
testcase_11 AC 41 ms
55,364 KB
testcase_12 AC 42 ms
55,364 KB
testcase_13 WA -
testcase_14 AC 42 ms
55,364 KB
testcase_15 WA -
testcase_16 AC 41 ms
55,364 KB
testcase_17 WA -
testcase_18 AC 43 ms
55,364 KB
testcase_19 AC 42 ms
55,364 KB
testcase_20 WA -
testcase_21 AC 43 ms
55,364 KB
testcase_22 AC 43 ms
55,364 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 124 ms
106,444 KB
testcase_42 WA -
testcase_43 AC 127 ms
105,800 KB
testcase_44 AC 124 ms
103,268 KB
testcase_45 AC 125 ms
107,324 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 87 ms
99,760 KB
testcase_49 AC 134 ms
133,368 KB
testcase_50 AC 133 ms
133,368 KB
testcase_51 AC 48 ms
61,848 KB
testcase_52 AC 120 ms
117,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
n = int(input())
s = input()
li = []
ans = 0
for i in range(n):
    if s[i] != "1" and s[i] != "9":
        ans += 1
    else:
        li.append(s[i])

idx = set()
d1 = deque()
#d9 = deque()

for i in range(len(li)):
    if li[i] == "1":
        d1.append(i)
    if li[i] == "9":
        if len(d1) > 0:
            tmp = d1.popleft()
            idx.add(tmp)
            idx.add(i)
            ans += 1
        
li2 = []
for i in range(len(li)):
    if i not in idx:
        li2.append(li[i])
#print(li2,ans,len(li2))
#exit()
idx = set()
flag = False
for i in range(len(li2)):
    if flag == False:
        if li2[i] == "1":
            flag = True
            tmp = i
    else:
        if li2[i] == "1":
            flag = False
            idx.add(tmp)
            idx.add(i)
            ans += 1
#print(ans,len(idx))
f = 0
for i in range(len(li2)):
    if i not in idx:
        if li2[i] == "9":
            f += 1
        else:
            if f >= 2:
                ans += 1
                break
            else:
                break
print(ans)
0