結果

問題 No.910 素数部分列
ユーザー hamuhei4869
提出日時 2019-10-18 21:46:08
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 599 bytes
コンパイル時間 1,739 ms
コンパイル使用メモリ 158,680 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-25 15:28:12
合計ジャッジ時間 3,155 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int MOD = 1e9+7;

int main()
{
    int N;
    string S;
    cin >> N;
    cin >> S;
    int ans = 0;
    ans += count(S.begin(), S.end(), '7');
    ans += count(S.begin(), S.end(), '3');
    ans += count(S.begin(), S.end(), '5');
    int one = 0;
    int u = 0;
    for(int i = 0;i < N;i++){
        if(S[i] == '1'){
            one++;
        }
        if(S[i] == '9' && one != 0){
            u++;
            one--;
        }
    }
    ans += u;
    ans += (count(S.begin(), S.end(), '1') - u)/2;
    cout<<ans<<endl;
}
0