結果

問題 No.910 素数部分列
ユーザー jxkoko
提出日時 2019-10-20 22:52:37
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 711 bytes
コンパイル時間 674 ms
コンパイル使用メモリ 83,272 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-02 17:33:00
合計ジャッジ時間 2,428 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
#include <set> 
using namespace std;

typedef long long ll;
typedef pair<ll, int> P;
typedef pair<pair<int, int>, int> PP;

int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

const ll INF = 1e15;
const int MAX = 510000;
const ll MOD = 1000000007;


int main(void) {
	int N; cin >> N;
	string S; cin >> S;
	int ichi = 0, ans = 0;
	
	for (int i = 0; i < N; i++) {
		if (S[i] == '1') ichi++;
		else if (S[i] == '9') {
			if (ichi > 0) {
				ans++; ichi--;
			}
		}
		else ans++;
	}
	ans += ichi / 2;
	cout << ans << endl;
}
0