Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.108 s | 12 KBi |
#2 |
Correcto
|
0.096 s | 12 KBi |
#3 |
Correcto
|
0.093 s | 12 KBi |
#4 |
Correcto
|
0.1 s | 12 KBi |
#5 |
Correcto
|
0.095 s | 11 KBi |
#6 |
Correcto
|
0.1 s | 11 KBi |
#7 |
Correcto
|
0.101 s | 12 KBi |
#8 |
Correcto
|
0.542 s | 23 KBi |
#9 |
Tiempo límite excedido
|
1.097 s | 27 KBi |
#10 |
Tiempo límite excedido
|
1.14 s | 26 KBi |
#11 |
Tiempo límite excedido
|
1.118 s | 26 KBi |
#12 |
Tiempo límite excedido
|
1.146 s | 28 KBi |
#13 |
Correcto
|
0.604 s | 43 KBi |
#14 |
Tiempo límite excedido
|
1.059 s | 24 KBi |
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader s = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); int n = Integer.parseInt(s.readLine()); String[] numsS = s.readLine().split(" "); int[] nums = new int[n]; for (int i = 0; i < n; i++) { nums[i] = Integer.parseInt(numsS[i]); } int queries = Integer.parseInt(s.readLine()); for (int i = 0; i < queries; i++) { String[] line = s.readLine().split(" "); int start = Integer.parseInt(line[0]); int end = Integer.parseInt(line[1]); int sum = 0; for (int j = start; j <= end; j++) { sum += nums[j]; } bw.write(sum + "\n"); } bw.close(); } }