Rezultati

Up. imeNalogaJezikRezultatČas oddaje
rektifikatorji-2018 Niz C++ 100/100OK 19. apr '18 @ 16:51

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 3,137 MiB 0,000 s OK
#2 10/10 3,137 MiB 0,000 s OK
#3 10/10 3,094 MiB 0,016 s OK
#4 10/10 3,094 MiB 0,010 s OK
#5 10/10 3,238 MiB 0,016 s OK
#6 10/10 3,094 MiB 0,010 s OK
#7 10/10 3,094 MiB 0,003 s OK
#8 10/10 3,234 MiB 0,016 s OK
#9 10/10 3,234 MiB 0,016 s OK
#10 10/10 3,234 MiB 0,016 s OK

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

using namespace std;

int main()
{
	int n;
	cin >> n;

	char* str = new char[n + 1];

	cin >> str;

	int cost = 0;
	for (int i = 0; i < n - 2; i++)
	{
		if (str[i] == '0' && str[i + 1] == '1' && str[i + 2] == '0')
		{
			str[i + 2] = '1';
			cost++;
		}
	}

	cout << cost << endl;
	return 0;
}