Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.086 s | 16 KBi |
#2 |
Correcto
|
0.111 s | 18 KBi |
#3 |
Correcto
|
0.368 s | 40 KBi |
#4 |
Tiempo límite excedido
|
1.058 s | 104 KBi |
#5 |
Tiempo límite excedido
|
1.052 s | 89 KBi |
#6 |
Error en tiempo de ejecución (NZEC)
Exited with error status 137 run: line 1: 3 Killed /usr/local/openjdk13/bin/java Main |
0.719 s | 125 KBi |
#7 |
Error en tiempo de ejecución (NZEC)
Exited with error status 137 run: line 1: 3 Killed /usr/local/openjdk13/bin/java Main |
0.717 s | 125 KBi |
#8 |
Error en tiempo de ejecución (NZEC)
Exited with error status 137 run: line 1: 3 Killed /usr/local/openjdk13/bin/java Main |
0.752 s | 125 KBi |
import java.util.ArrayList; import java.util.HashMap; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); HashMap<Integer, ArrayList<Integer>> memoization = new HashMap<>(); for(int i=0; i<n; i++){ int value = scanner.nextInt(); if(!memoization.containsKey(value)){ ArrayList<Integer> arrayList = new ArrayList<Integer>(); arrayList.add(i); memoization.put(value, arrayList); } else { memoization.get(value).add(i); } } int c = scanner.nextInt(); for(int i=0; i<c; i++){ int l = scanner.nextInt(); int r = scanner.nextInt(); int x = scanner.nextInt(); int count = 0; if(memoization.containsKey(x)) { ArrayList<Integer> arrayList = memoization.get(x); for (int j = 0; j < arrayList.size(); j++) { int value = arrayList.get(j); if (value >= l && value <= r) { count++; } } } System.out.println(count); } } }