Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.089 s | 16 KBi |
#2 |
Correcto
|
0.085 s | 16 KBi |
#3 |
Correcto
|
0.082 s | 16 KBi |
#4 |
Correcto
|
0.082 s | 16 KBi |
#5 |
Correcto
|
0.083 s | 16 KBi |
#6 |
Correcto
|
0.136 s | 49 KBi |
#7 |
Correcto
|
0.105 s | 16 KBi |
#8 |
Correcto
|
0.087 s | 16 KBi |
#9 |
Correcto
|
0.082 s | 16 KBi |
#10 |
Correcto
|
0.086 s | 16 KBi |
#11 |
Correcto
|
0.092 s | 16 KBi |
#12 |
Correcto
|
0.181 s | 25 KBi |
#13 |
Error en tiempo de ejecución (NZEC)
Exited with error status 137 run: line 1: 3 Killed /usr/local/openjdk13/bin/java Main |
0.213 s | 125 KBi |
#14 |
Error en tiempo de ejecución (NZEC)
Exited with error status 137 run: line 1: 3 Killed /usr/local/openjdk13/bin/java Main |
0.214 s | 125 KBi |
#15 |
Error en tiempo de ejecución (NZEC)
Exited with error status 137 run: line 1: 3 Killed /usr/local/openjdk13/bin/java Main |
0.212 s | 125 KBi |
import java.util.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int[][] clases = new int[n][n]; for(int i=0; i<n; i++){ String claseE = scanner.next(); String claseT = scanner.next(); int claseEmpieza = Integer.parseInt(claseE.replace(":", "")); int claseTermine = Integer.parseInt(claseT.replace(":", "")); clases[i][0]=claseEmpieza; clases[i][1]=claseTermine; } Sort2DArrayBasedOnColumnNumber(clases, 2); ArrayList<Integer> horarios = new ArrayList<>(); for(int i=0; i<n; i++){ if(i==0){ horarios.add(clases[i][1]); continue; } int min = Integer.MAX_VALUE; int minIndex = -1; for(int j=0; j<horarios.size(); j++){ if(horarios.get(j)<min){ min = horarios.get(j); minIndex = j; } } if(min<=clases[i][0]) { horarios.set(minIndex, clases[i][1]); } else { horarios.add(clases[i][1]); } } System.out.println(horarios.size()); } public static void Sort2DArrayBasedOnColumnNumber (int[][] array, final int columnNumber){ Arrays.sort(array, new Comparator<int[]>() { @Override public int compare(int[] first, int[] second) { if(first[columnNumber-1] > second[columnNumber-1]) return 1; else return -1; } }); } }