結果

問題 No.910 素数部分列
ユーザー 東前頭十一枚目
提出日時 2019-10-18 22:13:10
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 460 bytes
コンパイル時間 1,632 ms
コンパイル使用メモリ 167,556 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-25 17:07:30
合計ジャッジ時間 2,992 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11 WA * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	int n; cin >> n;
	string s; cin >> s;
	int num[2] = {};
	int ans = 0;
	for(char c : s) {
		if(c == '3' or c == '5' or c == '7') {
			++ans;
		} else {
			if(num[0] > 0) {
				++ans;
				--num[0];
			} else {
				if(c == '1') {
					if(num[1] > 2) {
						num[1] -= 2;
						++ans;
					} else {
						++num[0];
					}
				} else {
					++num[1];
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}
0