Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Error de compilación
main.c:1:1: error: unknown type name 'import' import java.util.HashMap; ^ main.c:1:12: error: expected ';' after top level declarator import java.util.HashMap; ^ ; main.c:2:1: error: unknown type name 'import' import java.util.Scanner; ^ main.c:2:12: error: expected ';' after top level declarator import java.util.Scanner; ^ ; main.c:4:1: error: unknown type name 'public' public class Main { ^ main.c:4:13: error: expected ';' after top level declarator public class Main { ^ ; 6 errors generated. |
||
#2 |
Error de compilación
main.c:1:1: error: unknown type name 'import' import java.util.HashMap; ^ main.c:1:12: error: expected ';' after top level declarator import java.util.HashMap; ^ ; main.c:2:1: error: unknown type name 'import' import java.util.Scanner; ^ main.c:2:12: error: expected ';' after top level declarator import java.util.Scanner; ^ ; main.c:4:1: error: unknown type name 'public' public class Main { ^ main.c:4:13: error: expected ';' after top level declarator public class Main { ^ ; 6 errors generated. |
||
#3 |
Error de compilación
main.c:1:1: error: unknown type name 'import' import java.util.HashMap; ^ main.c:1:12: error: expected ';' after top level declarator import java.util.HashMap; ^ ; main.c:2:1: error: unknown type name 'import' import java.util.Scanner; ^ main.c:2:12: error: expected ';' after top level declarator import java.util.Scanner; ^ ; main.c:4:1: error: unknown type name 'public' public class Main { ^ main.c:4:13: error: expected ';' after top level declarator public class Main { ^ ; 6 errors generated. |
||
#4 |
Error de compilación
main.c:1:1: error: unknown type name 'import' import java.util.HashMap; ^ main.c:1:12: error: expected ';' after top level declarator import java.util.HashMap; ^ ; main.c:2:1: error: unknown type name 'import' import java.util.Scanner; ^ main.c:2:12: error: expected ';' after top level declarator import java.util.Scanner; ^ ; main.c:4:1: error: unknown type name 'public' public class Main { ^ main.c:4:13: error: expected ';' after top level declarator public class Main { ^ ; 6 errors generated. |
||
#5 |
Error de compilación
main.c:1:1: error: unknown type name 'import' import java.util.HashMap; ^ main.c:1:12: error: expected ';' after top level declarator import java.util.HashMap; ^ ; main.c:2:1: error: unknown type name 'import' import java.util.Scanner; ^ main.c:2:12: error: expected ';' after top level declarator import java.util.Scanner; ^ ; main.c:4:1: error: unknown type name 'public' public class Main { ^ main.c:4:13: error: expected ';' after top level declarator public class Main { ^ ; 6 errors generated. |
||
#6 |
Error de compilación
main.c:1:1: error: unknown type name 'import' import java.util.HashMap; ^ main.c:1:12: error: expected ';' after top level declarator import java.util.HashMap; ^ ; main.c:2:1: error: unknown type name 'import' import java.util.Scanner; ^ main.c:2:12: error: expected ';' after top level declarator import java.util.Scanner; ^ ; main.c:4:1: error: unknown type name 'public' public class Main { ^ main.c:4:13: error: expected ';' after top level declarator public class Main { ^ ; 6 errors generated. |
||
#7 |
Error de compilación
main.c:1:1: error: unknown type name 'import' import java.util.HashMap; ^ main.c:1:12: error: expected ';' after top level declarator import java.util.HashMap; ^ ; main.c:2:1: error: unknown type name 'import' import java.util.Scanner; ^ main.c:2:12: error: expected ';' after top level declarator import java.util.Scanner; ^ ; main.c:4:1: error: unknown type name 'public' public class Main { ^ main.c:4:13: error: expected ';' after top level declarator public class Main { ^ ; 6 errors generated. |
||
#8 |
Error de compilación
main.c:1:1: error: unknown type name 'import' import java.util.HashMap; ^ main.c:1:12: error: expected ';' after top level declarator import java.util.HashMap; ^ ; main.c:2:1: error: unknown type name 'import' import java.util.Scanner; ^ main.c:2:12: error: expected ';' after top level declarator import java.util.Scanner; ^ ; main.c:4:1: error: unknown type name 'public' public class Main { ^ main.c:4:13: error: expected ';' after top level declarator public class Main { ^ ; 6 errors generated. |
||
#9 |
Error de compilación
main.c:1:1: error: unknown type name 'import' import java.util.HashMap; ^ main.c:1:12: error: expected ';' after top level declarator import java.util.HashMap; ^ ; main.c:2:1: error: unknown type name 'import' import java.util.Scanner; ^ main.c:2:12: error: expected ';' after top level declarator import java.util.Scanner; ^ ; main.c:4:1: error: unknown type name 'public' public class Main { ^ main.c:4:13: error: expected ';' after top level declarator public class Main { ^ ; 6 errors generated. |
||
#10 |
Error de compilación
main.c:1:1: error: unknown type name 'import' import java.util.HashMap; ^ main.c:1:12: error: expected ';' after top level declarator import java.util.HashMap; ^ ; main.c:2:1: error: unknown type name 'import' import java.util.Scanner; ^ main.c:2:12: error: expected ';' after top level declarator import java.util.Scanner; ^ ; main.c:4:1: error: unknown type name 'public' public class Main { ^ main.c:4:13: error: expected ';' after top level declarator public class Main { ^ ; 6 errors generated. |
import java.util.HashMap; import java.util.Scanner; public class Main { private static HashMap<Integer, Integer> memoization = new HashMap<Integer, Integer>(); public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int casosDePrueba = scanner.nextInt(); for(int caso=0; caso<casosDePrueba; caso++){ int n = scanner.nextInt(); int[] array = new int[n]; for(int i=0; i<n; i++){ array[i]=scanner.nextInt(); } findMaxSuffixArray(0, array); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("Case #" + (caso+1) +":"); for(int i=0; i<n; i++){ int value = array[i]; int horizon = findMaxSuffixArray(i+1, array); if(value>=horizon){ stringBuilder.append(" -1"); } else { stringBuilder.append(" " + horizon); } } System.out.println(stringBuilder); memoization = new HashMap<Integer, Integer>(); } } private static int findMaxSuffixArray(int start, int[] array){ if(memoization.containsKey(start)){ return memoization.get(start); } if(start == array.length){ memoization.put(start, -1); return -1; } int value = array[start]; int recResponse = findMaxSuffixArray(start+1, array); int max = Math.max(value, recResponse); memoization.put(start, max); return max; } }