Rezultati

Up. imeNalogaJezikRezultatČas oddaje
malitip Niz Java 100/100OK 19. apr '18 @ 17:02

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 35,430 MiB 0,000 s OK
#2 10/10 35,324 MiB 0,000 s OK
#3 10/10 40,414 MiB 0,000 s OK
#4 10/10 40,465 MiB 0,000 s OK
#5 10/10 42,758 MiB 0,000 s OK
#6 10/10 42,766 MiB 0,000 s OK
#7 10/10 39,684 MiB 0,000 s OK
#8 10/10 39,578 MiB 0,000 s OK
#9 10/10 39,586 MiB 0,000 s OK
#10 10/10 40,344 MiB 0,000 s OK

Ocenjevani program (Niz.java):
import java.util.Scanner;

public class Niz {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = Integer.valueOf(sc.nextLine());
        char [] s = sc.nextLine().toCharArray();
        int counter = 0;

        for (int i =2; i < n; i++) {
            if(s[i-2] == '0' && s[i-1] == '1' && s[i] == '0'){
                s[i] = '1';
                counter++;
            }
        }
        System.out.println(counter);

    }
}