Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.094 s | 13 KBi |
#2 |
Correcto
|
0.103 s | 13 KBi |
#3 |
Correcto
|
0.092 s | 13 KBi |
#4 |
Correcto
|
0.106 s | 13 KBi |
#5 |
Correcto
|
0.097 s | 13 KBi |
#6 |
Correcto
|
0.112 s | 14 KBi |
#7 |
Correcto
|
0.124 s | 14 KBi |
#8 |
Correcto
|
0.481 s | 34 KBi |
#9 |
Tiempo límite excedido
|
1.028 s | 101 KBi |
#10 |
Correcto
|
0.837 s | 98 KBi |
#11 |
Correcto
|
0.897 s | 97 KBi |
#12 |
Correcto
|
0.933 s | 100 KBi |
#13 |
Correcto
|
0.883 s | 97 KBi |
#14 |
Correcto
|
0.918 s | 97 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(); } }