Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.101 s | 13 KBi |
#2 |
Correcto
|
0.096 s | 13 KBi |
#3 |
Correcto
|
0.101 s | 13 KBi |
#4 |
Correcto
|
0.099 s | 13 KBi |
#5 |
Correcto
|
0.099 s | 13 KBi |
#6 |
Correcto
|
0.132 s | 14 KBi |
#7 |
Correcto
|
0.121 s | 14 KBi |
#8 |
Correcto
|
0.451 s | 33 KBi |
#9 |
Tiempo límite excedido
|
1.001 s | 100 KBi |
#10 |
Correcto
|
0.868 s | 97 KBi |
#11 |
Correcto
|
0.809 s | 100 KBi |
#12 |
Correcto
|
0.84 s | 98 KBi |
#13 |
Correcto
|
0.928 s | 100 KBi |
#14 |
Correcto
|
0.947 s | 103 KBi |
import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int[] array = new int[n]; int[] sumArray = new int[n + 1]; for (int i=0; i<n; i++){ array[i] = scanner.nextInt(); sumArray[i + 1] = sumArray[i] + array[i]; } int c = scanner.nextInt(); int p; int q; int[] resultArray = new int[c]; for (int i=0; i<c; i++){ p = scanner.nextInt(); q = scanner.nextInt(); resultArray[i] = sumArray[q+1]-sumArray[p]; } for (int element : resultArray) { System.out.println(element); } scanner.close(); } }