Rezultati

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

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

Ocenjevani program (Source.cpp):
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	int on[2] = { 0, 0 };
	string input;
	cin >> input;
	for (int i = 0; i < input.length(); ++i) {
		on[i % 2] += (int)input[i] - 48;
	}
	int lights[2] = { input.length() / 2 + input.length() % 2, input.length() / 2 };
	int oneOn = lights[0] - on[0] + on[1];
	int twoOn = lights[1] - on[1] + on[0];
	cout << min(oneOn, twoOn) << endl;

	//system("pause");
	return 0;
}