結果

問題 No.910 素数部分列
ユーザー brthyyjp
提出日時 2022-02-10 16:51:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 365 bytes
コンパイル時間 234 ms
コンパイル使用メモリ 82,060 KB
実行使用メモリ 84,880 KB
最終ジャッジ日時 2024-06-25 23:23:27
合計ジャッジ時間 4,124 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = list(str(input()))
s.reverse()

ans = 0
cnt1 = 0
cnt9 = 0
for c in s:
    if c == '3' or c == '5' or c == '7':
        ans += 1
    elif c == '1':
        if cnt1:
            cnt1 -= 1
            ans += 1
        elif cnt9:
            cnt9 -= 1
            ans += 1
        else:
            cnt1 += 1
    else:
        cnt9 += 1
print(ans)
0