69072023-12-19 16:28:25999Takaros Sorozat (80 pont)cpp17Wrong answer 12/806ms4244 KiB
// Source: https://usaco.guide/general/io

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

int main() {
	int n;cin>>n;
	string v; cin>>v;
	bool vane1=false,vane0=false;
	int cnt1=0;
	int cnt0=0;
	v='2'+v+'2';
	int i = 1;
	while(i<=n){
		if(v[i]=='0'&&vane1){
			cnt0++;
			if(v[i+1]=='0'){
				i+=2;
				continue;
			}
		}
		if(v[i]=='1')vane1=true;
		i++;
	}
	while(i>0){
		if(v[i]=='1'&&vane0){
			cnt1++;
			if(v[i-1]=='1'){
				i-=2;
				continue;
			}
		}
		if(v[i]=='0')vane0=true;
		i--;
	}
	cout<<min(cnt1,cnt0)<<endl;
}
SubtaskSumTestVerdictTimeMemory
base12/80
1Wrong answer0/03ms1968 KiB
2Wrong answer0/06ms2764 KiB
3Partially correct2/43ms2544 KiB
4Partially correct2/43ms2680 KiB
5Partially correct2/43ms2924 KiB
6Wrong answer0/43ms3136 KiB
7Wrong answer0/43ms3000 KiB
8Partially correct2/43ms3028 KiB
9Wrong answer0/43ms3180 KiB
10Wrong answer0/43ms3412 KiB
11Wrong answer0/43ms3492 KiB
12Wrong answer0/43ms3532 KiB
13Partially correct2/44ms3968 KiB
14Wrong answer0/44ms3976 KiB
15Partially correct2/44ms3860 KiB
16Wrong answer0/44ms3856 KiB
17Wrong answer0/44ms3856 KiB
18Wrong answer0/46ms4136 KiB
19Wrong answer0/44ms3980 KiB
20Wrong answer0/46ms3992 KiB
21Wrong answer0/46ms3984 KiB
22Wrong answer0/46ms4244 KiB