Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Incorrecto
|
0.121 s | 14 KBi |
#2 |
Incorrecto
|
0.127 s | 17 KBi |
#3 |
Incorrecto
|
0.119 s | 14 KBi |
#4 |
Incorrecto
|
0.118 s | 17 KBi |
#5 |
Incorrecto
|
0.129 s | 17 KBi |
#6 |
Error en tiempo de ejecución (NZEC)
Exited with error status 137 run: line 1: 3 Killed /usr/local/openjdk13/bin/java Main |
0.47 s | 125 KBi |
#7 |
Error en tiempo de ejecución (NZEC)
Exited with error status 137 run: line 1: 3 Killed /usr/local/openjdk13/bin/java Main |
0.617 s | 125 KBi |
#8 |
Error en tiempo de ejecución (NZEC)
Exited with error status 137 run: line 1: 3 Killed /usr/local/openjdk13/bin/java Main |
0.516 s | 125 KBi |
#9 |
Error en tiempo de ejecución (NZEC)
Exited with error status 137 run: line 1: 3 Killed /usr/local/openjdk13/bin/java Main |
0.504 s | 125 KBi |
#10 |
Error en tiempo de ejecución (NZEC)
Exited with error status 137 run: line 1: 3 Killed /usr/local/openjdk13/bin/java Main |
0.745 s | 125 KBi |
import java.util.AbstractMap; import java.util.Map; import java.util.Scanner; import java.util.Stack; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int c = scanner.nextInt(); for(int i=0; i<c; i++){ int n = scanner.nextInt(); int[] buildings = new int[n]; int[] buildingsResults = new int[n]; for(int j=0; j<buildings.length; j++){ buildings[j]=scanner.nextInt(); buildingsResults[j] = -1; } Stack<Map.Entry<Integer, Integer>> stack = new Stack<>(); for(int j=0; j<buildings.length; j++){ Map.Entry<Integer, Integer> value = new AbstractMap.SimpleEntry<>(j, buildings[j]); while (!stack.isEmpty() && stack.peek().getValue() < buildings[j]){ Map.Entry<Integer, Integer> stackedValue = stack.pop(); buildingsResults[stackedValue.getKey()] = buildings[j]; } stack.add(value); } System.out.print("Case #" +(i+1) +": "); for(int j=0; j<buildingsResults.length; j++){ if(j == buildings.length-1){ System.out.print(buildingsResults[j]); } System.out.print(buildingsResults[j] + " "); } } } }