結果

問題 No.3114 0→1
ユーザー daiota
提出日時 2025-04-19 18:27:26
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 508 bytes
コンパイル時間 1,726 ms
コンパイル使用メモリ 160,876 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-04-19 18:27:30
合計ジャッジ時間 3,049 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i=0;i<ll(n);i++)








int main(void){
	cin.tie(nullptr);  ios_base::sync_with_stdio(false);
	ll i,j;




	ll N;
	string S;
	cin >> N >> S;


	ll ans=0;
	REP(i,N){
		if(S[i]=='0'){
			if(i+1<N){
				if(S[i+1]=='0'){
					ans++;
					S[i+1]='1';
				}
			}
			if(i+2<N){
				if(S[i+2]=='0'){
						ans++;
						S[i+2]='1';
				}
			}
		}
	}






	cout << ans << endl;






	return 0;

}

0