Rezultati

Up. imeNalogaJezikRezultatČas oddaje
CryADsisAM Hodnik Java 100/100OK 20. apr '17 @ 17:23

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 34,559 MiB 0,000 s OK
#2 10/10 34,602 MiB 0,000 s OK
#3 10/10 34,523 MiB 0,000 s OK
#4 10/10 34,281 MiB 0,000 s OK
#5 10/10 36,020 MiB 0,000 s OK
#6 10/10 37,805 MiB 0,000 s OK
#7 10/10 35,516 MiB 0,000 s OK
#8 10/10 34,852 MiB 0,000 s OK
#9 10/10 37,789 MiB 0,000 s OK
#10 10/10 31,035 MiB 0,000 s OK

Ocenjevani program (Druga (1).java):
import java.util.Scanner;

public class Druga {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int c1 = 0;
        int c2 = 0;

        char[] valid = {'0', '1'};
        for (int i = 0; i < s.length(); i++)
            if (valid[i % 2] != s.charAt(i)) c1++;
        for (int i = 0; i < s.length(); i++)
            if (valid[(i + 1) % 2] != s.charAt(i)) c2++;

        System.out.println(c1 > c2 ? c2 : c1);


    }
}