Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.223 s | 13 KBi |
#2 |
Incorrecto
|
0.226 s | 15 KBi |
#3 |
Correcto
|
0.215 s | 13 KBi |
#4 |
Correcto
|
0.192 s | 14 KBi |
#5 |
Correcto
|
0.226 s | 17 KBi |
#6 |
Tiempo límite excedido
|
0.355 s | 27 KBi |
#7 |
Tiempo límite excedido
|
1.046 s | 106 KBi |
#8 |
Tiempo límite excedido
|
1.023 s | 60 KBi |
#9 |
Tiempo límite excedido
|
1.01 s | 104 KBi |
#10 |
Tiempo límite excedido
|
1.084 s | 119 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); } } }