Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Error de compilación
Compilation time limit exceeded. |
||
#2 |
Error de compilación
Compilation time limit exceeded. |
||
#3 |
Error de compilación
Compilation time limit exceeded. |
||
#4 |
Error de compilación
Compilation time limit exceeded. |
||
#5 |
Correcto
Note: Main.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. |
0.251 s | 54 KBi |
#6 |
Tiempo límite excedido
Note: Main.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. |
1.031 s | 101 KBi |
#7 |
Tiempo límite excedido
Note: Main.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. |
0.717 s | 60 KBi |
#8 |
Tiempo límite excedido
Note: Main.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. |
1.031 s | 61 KBi |
#9 |
Tiempo límite excedido
Note: Main.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. |
1.169 s | 72 KBi |
#10 |
Tiempo límite excedido
Note: Main.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. |
1.009 s | 56 KBi |
import java.util.Scanner; import java.util.Stack; public class Main { public static long[] processLine(int N, Scanner myObj) { long elements[] = new long[N]; for (int i=0; i < N; i++) { elements[i] = myObj.nextLong(); } return elements; } public static long[] solve(int N, long[] elements) { long[] solution; Stack<Long> max; solution = new long[N]; max = new Stack<Long>(); for (int i = N-1; i >= 0; i--) { while (!max.empty() && elements[i] >= max.peek()) { max.pop(); } solution[i] = max.empty() ? -1 : max.peek(); max.push(new Long(elements[i])); } return solution; } public static void printCase(int i, long[] solution) { System.out.print("Case #" + i + ":"); for (long e: solution) { System.out.print(" " + e); } System.out.println(""); } public static void main(String ...args) { int N, C; long[] elements, solution; Scanner myObj = new Scanner(System.in); C = myObj.nextInt(); for(int i=1; i<=C; i++) { N = myObj.nextInt(); elements = processLine(N, myObj); solution = solve(N, elements); printCase(i, solution); } } }