69062023-12-19 16:26:06999Takaros Sorozat (80 pont)cpp17Wrong answer 12/807ms4872 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,elozo0=false,elozo1=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++;
		}
		if(v[i]=='1')vane1=true;
		i++;
	}
	while(i>0){
		if(v[i]=='1'&&vane0){
			cnt1++;
			if(v[i-1]=='1')i--;
		}
		if(v[i]=='0')vane0=true;
		i--;
	}
	cout<<min(cnt1,cnt0)<<endl;
}
SubtaskSumTestVerdictTimeMemory
base12/80
1Wrong answer0/03ms2088 KiB
2Wrong answer0/07ms2796 KiB
3Partially correct2/43ms2352 KiB
4Partially correct2/43ms2472 KiB
5Partially correct2/43ms2712 KiB
6Wrong answer0/43ms2960 KiB
7Wrong answer0/43ms3132 KiB
8Partially correct2/43ms3100 KiB
9Wrong answer0/43ms3352 KiB
10Wrong answer0/43ms3348 KiB
11Wrong answer0/43ms3476 KiB
12Wrong answer0/43ms3540 KiB
13Partially correct2/46ms4096 KiB
14Wrong answer0/46ms4296 KiB
15Partially correct2/46ms4136 KiB
16Wrong answer0/46ms4136 KiB
17Wrong answer0/46ms4188 KiB
18Wrong answer0/46ms4444 KiB
19Wrong answer0/46ms4344 KiB
20Wrong answer0/47ms4408 KiB
21Wrong answer0/47ms4660 KiB
22Wrong answer0/47ms4872 KiB