Rezultati

Up. imeNalogaJezikRezultatČas oddaje
abr Hodnik Java 100/100OK 20. apr '17 @ 16:38

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 30,324 MiB 0,000 s OK
#2 10/10 35,113 MiB 0,000 s OK
#3 10/10 33,215 MiB 0,000 s OK
#4 10/10 34,070 MiB 0,000 s OK
#5 10/10 31,352 MiB 0,000 s OK
#6 10/10 35,922 MiB 0,000 s OK
#7 10/10 35,855 MiB 0,000 s OK
#8 10/10 39,750 MiB 0,000 s OK
#9 10/10 45,066 MiB 0,000 s OK
#10 10/10 38,922 MiB 0,000 s OK

Ocenjevani program (Hodnik.java):
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Hodnik {
	public static void main(String[] args) throws Exception{
		BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
		String ln = read.readLine();
		String h1="";
		String h2= "";
		int i1 = 0;
		int i2 = 1;
		for (int i = 0; i < ln.length(); i++) {
			h1= h1 + ""+i1;
			h2=h2 + ""+i2;
			i1 = (i1 +1) %2;
			i2 = (i2 +1) %2;
		}
		int dif1=0;
		int dif2=0;
		for (int i = 0; i < ln.length(); i++) {
			if(ln.charAt(i) != h1.charAt(i))
				dif1++;
			if(ln.charAt(i) != h2.charAt(i))
				dif2++;
		}
		System.out.println(Math.min(dif1, dif2));
	}

}