Rezultati

Up. imeNalogaJezikRezultatČas oddaje
hl3-2018 Niz Java 100/100OK 19. apr '18 @ 18:41

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 38,184 MiB 0,000 s OK
#2 10/10 25,668 MiB 0,000 s OK
#3 10/10 43,895 MiB 0,000 s OK
#4 10/10 50,742 MiB 0,000 s OK
#5 10/10 43,336 MiB 0,000 s OK
#6 10/10 47,953 MiB 0,000 s OK
#7 10/10 48,078 MiB 0,000 s OK
#8 10/10 48,805 MiB 0,000 s OK
#9 10/10 42,273 MiB 0,000 s OK
#10 10/10 46,934 MiB 0,000 s OK

Ocenjevani program (Main.java):
//package com.company;
import java.util.*;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner sc = new Scanner(System.in);
        int dolzina = sc.nextInt();
        sc.nextLine();
        String ln = sc.nextLine();
        sc.close();
        int i = 0;
        int count = 0;
        while(dolzina - 2 > i){
            if((dolzina - i - 4 > 0) && ln.substring(i, i+5).equals("01010")){
                count++;
                i+=4;
            }else if((dolzina - i - 2 > 0) && ln.substring(i,i+3).equals("010")){
                count++;
                i+=2;
            }else{
                i++;
            }
        }
        System.out.println(count);
    }
}