TOPIC

5% Wrong Answer

bggdsantos asked 3 years ago

Não sei o que pode estar de errado, já testei todos os casos de testes dp uDebug e outros, mas não consigo o Accept.

public static void autenticar() {
        if(primeiro==false) {
        quantidade = Integer.parseInt(numeros);
        numeros=ler.nextLine();
        objetivo=quantidade;}
        else {
            primeiro=false;}
        }
    public static boolean conferir(int objetivo) {
        if(estacao.empty()==false) {
        if(estacao.peek()==objetivo) {
            return true;}
        }
        return false;}
    public static void main(String[]args) {
        ler = new Scanner(System.in);
        int quantidade = Integer.parseInt(ler.nextLine());
        int objetivo=quantidade;
        numeros=ler.nextLine();
        while(numeros.equals("0")==false && ler.hasNext()) {
            autenticar();
        while(numeros.equals("0")==false && ler.hasNext()) {
            String[] n=numeros.split(" ");
            for(int i=0;i<n.length;i++) {
                a.push(Integer.parseInt(n[i])); }   
            while(a.empty()==false) {
                while(conferir(objetivo)&&estacao.empty()==false) { 
                    b.push(estacao.peek());
                    estacao.pop();
                    objetivo=objetivo-1;    }
                if(a.peek()==objetivo) {
                    b.push(a.peek());
                    a.pop();
                    objetivo=objetivo-1;}
                else {
                    estacao.push(a.peek());
                    a.pop();}
          }
            while(estacao.empty()==false) {
                if(estacao.peek()==objetivo) {
                    b.push(estacao.peek());
                    estacao.pop();
                    objetivo=objetivo-1;}
                else {
                    break;}
            }
            numeros=ler.nextLine();
            if(numeros.equals("0")) {
                if(b.size()==quantidade) {
                    System.out.println("Yes\n");    }
                else {
                    System.out.println("No\n");}
            }
            else {
            if(b.size()==quantidade) {
                System.out.println("Yes");}
            else {
                System.out.println("No");}
            }
            b.clear();
            a.clear();
            estacao.clear();
            objetivo=quantidade;}
        numeros=ler.nextLine();}
    ler.close();}
  }

This topic has not been answered yet. Be the first!

Remember not post solutions. Your post may be reviewed by our moderators.