Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.223 s | 51 KBi |
#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 |
Error de compilación
Compilation time limit exceeded. |
||
#6 |
Tiempo límite excedido
|
0.827 s | 57 KBi |
#7 |
Tiempo límite excedido
|
1.001 s | 111 KBi |
#8 |
Tiempo límite excedido
|
0.983 s | 77 KBi |
#9 |
Tiempo límite excedido
|
0.959 s | 86 KBi |
#10 |
Tiempo límite excedido
|
0.782 s | 61 KBi |
import java.util.Scanner; 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; int maxPos; long max; maxPos = N-1; solution = new long[N]; solution[maxPos] = -1; max = elements[maxPos]; for (int i = maxPos - 1; i >= 0; i--) { solution[i] = -1; if (elements[i] < elements[i+1]) { max = elements[i+1]; solution[i] = max; } else if (elements[i] < max){ solution[i] = max; } } 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); } } }