結果
| 問題 | No.910 素数部分列 | 
| コンテスト | |
| ユーザー |  kurimupy | 
| 提出日時 | 2020-06-18 01:49:14 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 87 ms / 1,000 ms | 
| コード長 | 694 bytes | 
| コンパイル時間 | 199 ms | 
| コンパイル使用メモリ | 82,376 KB | 
| 実行使用メモリ | 85,284 KB | 
| 最終ジャッジ日時 | 2024-07-03 12:36:58 | 
| 合計ジャッジ時間 | 5,192 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 50 | 
ソースコード
# problem 1
N = int(input())
S = list(input())
ans = 0
dic = {"1": 0, "3": 0, "5": 0, "7": 0, "9": 0}
for some in S:
    dic[some] += 1
ans = dic["3"]+dic["5"]+dic["7"]
new = {1: 0, 9: 0}
for x in S:
    n = int(x)
    if n == 1: new[1] += 1
    if n == 9:
        new[9] += 1
        
        if new[9]>0 and new[1] > 0:
            new[1] -= 1
            new[9] -= 1
            ans += 1
if new[9] >= new[1]*2:
    ans += new[1]
    print(ans)
    exit()
    
elif new[9] < new[1]*2:
    if new[9]>1:
        p = new[9]//2
        ans += p
        new[1] -= p
        ans += new[1]//2
        print(ans)
        exit()
    else:
        ans += new[1]//2
        print(ans)
        exit()
            
            
            
        