Rezultati

Up. imeNalogaJezikRezultatČas oddaje
EOF-2017 Hodnik C++ 100/100OK 20. apr '17 @ 16:28

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 3,055 MiB 0,004 s OK
#2 10/10 3,113 MiB 0,004 s OK
#3 10/10 3,109 MiB 0,004 s OK
#4 10/10 3,109 MiB 0,004 s OK
#5 10/10 3,105 MiB 0,004 s OK
#6 10/10 3,117 MiB 0,004 s OK
#7 10/10 3,125 MiB 0,004 s OK
#8 10/10 3,121 MiB 0,004 s OK
#9 10/10 3,121 MiB 0,004 s OK
#10 10/10 3,125 MiB 0,004 s OK

Ocenjevani program (Hodnik.cpp):
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
	int counter[2] = {0, 0};
	bool current = true;
	string s;
	
	cin>>s;
	
	for(int i=0; i<(int)s.size(); i++){
		if((s[i] == '0') == current){
			counter[0]++;
		}
		else{
			counter[1]++;
		}
		current = !current;
	}
	cout<<min(counter[0], counter[1]);
	
	return 0;
}