Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.139 s | 12 KBi |
#2 |
Correcto
|
0.168 s | 13 KBi |
#3 |
Correcto
|
0.176 s | 13 KBi |
#4 |
Correcto
|
0.184 s | 13 KBi |
#5 |
Correcto
|
0.17 s | 13 KBi |
#6 |
Correcto
|
0.165 s | 13 KBi |
#7 |
Correcto
|
0.133 s | 12 KBi |
#8 |
Correcto
|
0.125 s | 12 KBi |
#9 |
Correcto
|
0.173 s | 13 KBi |
#10 |
Correcto
|
0.182 s | 13 KBi |
#11 |
Correcto
|
0.4 s | 17 KBi |
#12 |
Correcto
|
0.248 s | 15 KBi |
#13 |
Correcto
|
0.37 s | 17 KBi |
#14 |
Correcto
|
0.262 s | 15 KBi |
#15 |
Correcto
|
0.394 s | 17 KBi |
#16 |
Correcto
|
0.234 s | 15 KBi |
#17 |
Correcto
|
0.374 s | 16 KBi |
#18 |
Correcto
|
0.285 s | 15 KBi |
#19 |
Correcto
|
0.4 s | 18 KBi |
#20 |
Correcto
|
0.382 s | 17 KBi |
import java.util.Scanner; public class Main { public static void swap(int[] a, int i, int j) { int t = a[i]; a[i] = a[j]; a[j] = t; } public static void main(String[] args) { Scanner cin = new Scanner(System.in); int N = cin.nextInt(); int[] array = new int[N]; for (int i = 0; i < N; i++){ array[i] = cin.nextInt(); } for (int i = 0; i < N; i++) { for (int j = 0; j + 1 < N; j++) { if (array[j] > array[j+1]) { swap(array, j, j+1); } } } for (int i = 0; i < N; i++) { if (i > 0) System.out.print(" "); System.out.print(array[i]); } System.out.println(""); } }