Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Error de compilación
Compilation time limit exceeded. |
||
#2 |
Incorrecto
|
0.199 s | 15 KBi |
#3 |
Correcto
|
0.197 s | 19 KBi |
#4 |
Correcto
|
0.187 s | 16 KBi |
#5 |
Correcto
|
0.2 s | 15 KBi |
#6 |
Tiempo límite excedido
|
1.066 s | 84 KBi |
#7 |
Tiempo límite excedido
|
1.006 s | 61 KBi |
#8 |
Tiempo límite excedido
|
1.048 s | 83 KBi |
#9 |
Tiempo límite excedido
|
1.003 s | 71 KBi |
#10 |
Tiempo límite excedido
|
1.068 s | 81 KBi |
import java.util.Scanner; class Main { public static long[] processLine(int N, String line) { long elements[] = new long[N]; String strElements[] = line.split(" "); for (int i=0; i < N; i++) { elements[i] = Long.parseLong(strElements[i]); } 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; String line; long[] elements, solution; Scanner myObj = new Scanner(System.in); C = Integer.parseInt(myObj.nextLine().trim()); for(int i=1; i<=C; i++) { N = Integer.parseInt(myObj.nextLine().trim()); line = myObj.nextLine(); elements = processLine(N, line); solution = solve(N, elements); printCase(i, solution); } } }