Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.117 s | 13 KBi |
#2 |
Correcto
|
0.119 s | 13 KBi |
#3 |
Correcto
|
0.107 s | 13 KBi |
#4 |
Correcto
|
0.126 s | 13 KBi |
#5 |
Correcto
|
0.122 s | 13 KBi |
#6 |
Correcto
|
0.147 s | 14 KBi |
#7 |
Correcto
|
0.152 s | 15 KBi |
#8 |
Correcto
|
0.613 s | 34 KBi |
#9 |
Tiempo límite excedido
|
1.079 s | 97 KBi |
#10 |
Tiempo límite excedido
|
1.048 s | 94 KBi |
#11 |
Tiempo límite excedido
|
1.043 s | 98 KBi |
#12 |
Correcto
|
0.975 s | 96 KBi |
#13 |
Tiempo límite excedido
|
1.046 s | 99 KBi |
#14 |
Tiempo límite excedido
|
1.039 s | 101 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); } } }