Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Incorrecto
|
0.148 s | 18 KBi |
#2 |
Incorrecto
|
0.154 s | 16 KBi |
#3 |
Incorrecto
|
0.161 s | 16 KBi |
#4 |
Incorrecto
|
0.148 s | 16 KBi |
#5 |
Incorrecto
|
0.146 s | 16 KBi |
#6 |
Incorrecto
|
0.139 s | 18 KBi |
#7 |
Incorrecto
|
0.148 s | 16 KBi |
#8 |
Incorrecto
|
0.129 s | 16 KBi |
#9 |
Incorrecto
|
0.159 s | 16 KBi |
#10 |
Incorrecto
|
0.184 s | 16 KBi |
#11 |
Incorrecto
|
0.161 s | 51 KBi |
#12 |
Incorrecto
|
0.358 s | 53 KBi |
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sn = new Scanner(System.in); int size = Integer.parseInt(sn.nextLine()); String[] arItems = sn.nextLine().split(" "); Integer[] entries = new Integer[size]; for (int i = 0; i < size; i++) { int arItem = Integer.parseInt(arItems[i]); entries[i] = arItem; } // bubbleSort bubbleSort(entries, size); //print array for (int i = 0; i < size; i++) { System.out.println(entries[i]); } } private static void bubbleSort(Integer[] entries, int size) { for (int i = 0; i < size; i++) { for (int j = 0; j+1 < size; j++) { if (entries[j] > entries[j+1]) swap(entries, i, j); } } } private static void swap(Integer[] ar, int a, int b) { int temp = ar[a]; ar[a] = ar[b]; ar[b] = temp; } }