Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.133 s | 13 KBi |
#2 |
Correcto
|
0.118 s | 13 KBi |
#3 |
Correcto
|
0.133 s | 13 KBi |
#4 |
Correcto
|
0.135 s | 13 KBi |
#5 |
Correcto
|
0.128 s | 13 KBi |
#6 |
Correcto
|
0.163 s | 14 KBi |
#7 |
Correcto
|
0.151 s | 13 KBi |
#8 |
Correcto
|
0.649 s | 35 KBi |
#9 |
Tiempo límite excedido
|
1.064 s | 87 KBi |
#10 |
Tiempo límite excedido
|
1.078 s | 97 KBi |
#11 |
Tiempo límite excedido
|
1.092 s | 100 KBi |
#12 |
Tiempo límite excedido
|
1.012 s | 99 KBi |
#13 |
Tiempo límite excedido
|
1.032 s | 98 KBi |
#14 |
Tiempo límite excedido
|
1.046 s | 98 KBi |
import java.util.Scanner; public class Main { public void solve(int[] a, int[] s, int p, int q) { int sum = s[q]; if (p-1 >= 0) { sum -= s[p - 1]; } System.out.println(sum); } public static void main(String[] args) { Main solve = new Main(); Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int [] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); } int[] s = new int[n]; int sum = 0; for (int i = 0; i < n; i++) { sum += a[i]; s[i] = sum; } int c = sc.nextInt(); int p = 0; int q = 0; for (int k = 0; k < c; k++) { p = sc.nextInt(); q = sc.nextInt(); solve.solve(a, s, p, q); } } }