Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.103 s | 13 KBi |
#2 |
Correcto
|
0.102 s | 12 KBi |
#3 |
Correcto
|
0.093 s | 12 KBi |
#4 |
Correcto
|
0.117 s | 18 KBi |
#5 |
Correcto
|
0.092 s | 12 KBi |
#6 |
Correcto
|
0.119 s | 13 KBi |
#7 |
Correcto
|
0.104 s | 13 KBi |
#8 |
Correcto
|
0.507 s | 24 KBi |
#9 |
Tiempo límite excedido
|
1.046 s | 27 KBi |
#10 |
Tiempo límite excedido
|
1.015 s | 26 KBi |
#11 |
Tiempo límite excedido
|
1.079 s | 27 KBi |
#12 |
Tiempo límite excedido
|
1.05 s | 27 KBi |
#13 |
Correcto
|
0.575 s | 44 KBi |
#14 |
Tiempo límite excedido
|
1.069 s | 29 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(" "); short[] nums = new short[n]; for (int i = 0; i < n; i++) { nums[i] = Short.parseShort(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(); } }