Rezultati

Up. imeNalogaJezikRezultatČas oddaje
lml-2018 Niz Java 100/100OK 19. apr '18 @ 16:59

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 35,773 MiB 0,000 s OK
#2 10/10 35,629 MiB 0,000 s OK
#3 10/10 39,430 MiB 0,000 s OK
#4 10/10 39,789 MiB 0,000 s OK
#5 10/10 35,305 MiB 0,000 s OK
#6 10/10 39,648 MiB 0,000 s OK
#7 10/10 42,816 MiB 0,000 s OK
#8 10/10 39,039 MiB 0,000 s OK
#9 10/10 39,492 MiB 0,000 s OK
#10 10/10 44,926 MiB 0,000 s OK

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

public class Niz
{
    public static void main(String[] args)
    {
        Scanner skan = new Scanner(System.in);
        String bla = skan.nextLine();
        String s = skan.nextLine();
        char[] niz = s.toCharArray();
        int count = 0;

        for(int i = 2; i < niz.length; i++)
        {
            if(niz[i] == '0' && niz[i - 1] == '1' && niz[i - 2] == '0')
            {
                niz[i] = '1';
                count++;
            }
        }

        System.out.println(count);
    }
}