結果

問題 No.910 素数部分列
ユーザー alexara1123
提出日時 2019-10-18 22:14:33
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 790 bytes
コンパイル時間 74 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-06-25 17:09:43
合計ジャッジ時間 3,018 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other RE * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

from fractions import gcd
from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7


def main():
    n = int(input())
    s = list(input())
    s2 = []
    ans = 0
    for i in range(n):
        if s[i] == "3" or s[i] == "5" or s[i] == "7":
            ans += 1
        else:
            s2.append(s[i])
    
    one, nine = 0, 0
    for i in range(len(s2)):
        if s2[i] == "1":
            one+=1
        elif s2[i] == "9":
            if one > 0:
                ans += 1
                one -= 1
    ans += (one // 2)
    print(ans)


    
            
    

    

    

if __name__ == '__main__':
    main()
0