結果

問題 No.910 素数部分列
ユーザー face4
提出日時 2019-10-18 21:55:27
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 615 bytes
コンパイル時間 673 ms
コンパイル使用メモリ 64,256 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-25 15:47:21
合計ジャッジ時間 2,315 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 WA * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

// ???
#include<iostream>
using namespace std;

int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans = 0, one = 0, five = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == '3' || s[i] == '7'){
            ans++;
            continue;
        }
        if(s[i] == '9'){
            if(five > 0){
                ans++;
                five--;
            }else if(one > 0){
                ans++;
                one--;
            }
        }else if(s[i] == '1'){
            one++;
        }else if(s[i] == '5'){
            five++;
        }
    }
    cout << ans+one/2 << endl;
    return 0;
}
0