結果

問題 No.910 素数部分列
ユーザー misora192
提出日時 2020-07-24 22:30:04
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 622 bytes
コンパイル時間 1,719 ms
コンパイル使用メモリ 165,648 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-25 22:00:03
合計ジャッジ時間 3,143 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

	string s;
	cin >> s;

	int one = 0;
	int ans = 0;
	rep(i, n){
		if(s[i] == '3' || s[i] == '5' || s[i] == '7') ans++;
		if(s[i] == '1') one++;
		if(s[i] == '9'){
			if(one > 0){
				one--;
				ans++;
			}
		}
	}

	ans += one / 2;
	cout << ans << endl;
}
0