69092023-12-19 16:48:44999Takaros Sorozat (80 pont)cpp17Wrong answer 24/807ms5428 KiB
// Source: https://usaco.guide/general/io

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

int main() {
	int n;cin>>n;
	string s; cin>>s;
	bool vane1=false,vane0=false;
	int cnt1=0,hely1=0;
	int cnt0=0,hely0=0;
	vector<int> v(n+1);
	for(int i = 0;i<n;i++){
		v[i+1]=s[i]-'0';
		if(v[i+1]==1&&!vane1){
			hely1=i+1;
			vane1=true;
		}
		if(v[i+1]==0)hely0=i+1;
	}
	for(int i = 1;i<=n;i++){
		if(i>hely1&&v[i]==0){
			cnt0++;
			if(i<n-1&&v[i+1]==0)i++;
		}
	}
	for(int i = n;i>=1;i--){
		if(i<hely0&&v[i]==1){
			cnt1++;
			if(v[i-1]==1)i--;
		}
	}
	cout<<min(cnt1,cnt0)<<endl;
	cout<<min(cnt1,cnt0)<<endl;
}
SubtaskSumTestVerdictTimeMemory
base24/80
1Wrong answer0/03ms1812 KiB
2Wrong answer0/07ms3016 KiB
3Accepted4/43ms2216 KiB
4Accepted4/43ms2480 KiB
5Partially correct2/43ms2544 KiB
6Wrong answer0/43ms2596 KiB
7Wrong answer0/43ms2740 KiB
8Accepted4/43ms2924 KiB
9Wrong answer0/43ms3132 KiB
10Wrong answer0/43ms3344 KiB
11Wrong answer0/43ms3584 KiB
12Partially correct2/43ms3636 KiB
13Accepted4/44ms4728 KiB
14Partially correct2/44ms4940 KiB
15Partially correct2/46ms4980 KiB
16Wrong answer0/46ms5156 KiB
17Wrong answer0/44ms5296 KiB
18Wrong answer0/46ms5144 KiB
19Wrong answer0/46ms5144 KiB
20Wrong answer0/47ms5144 KiB
21Wrong answer0/47ms5140 KiB
22Wrong answer0/47ms5428 KiB