Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.085 s | 11 KBi |
#2 |
Correcto
|
0.089 s | 11 KBi |
#3 |
Correcto
|
0.091 s | 11 KBi |
#4 |
Correcto
|
0.091 s | 11 KBi |
#5 |
Correcto
|
0.061 s | 10 KBi |
#6 |
Correcto
|
0.077 s | 10 KBi |
#7 |
Correcto
|
0.103 s | 11 KBi |
#8 |
Correcto
|
0.566 s | 20 KBi |
#9 |
Correcto
|
0.84 s | 32 KBi |
#10 |
Tiempo límite excedido
|
1.074 s | 34 KBi |
#11 |
Correcto
|
0.766 s | 31 KBi |
#12 |
Correcto
|
0.722 s | 30 KBi |
#13 |
Correcto
|
0.798 s | 33 KBi |
#14 |
Correcto
|
0.973 s | 36 KBi |
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(reader.readLine()); int []array = new int[N]; int []sums = new int[N]; int sum = 0; StringTokenizer tk = new StringTokenizer(reader.readLine()); int i =0; while(tk.hasMoreTokens()){ array[i] = Integer.parseInt(tk.nextToken()); sum += array[i]; sums[i] = sum; i++; } int c = Integer.parseInt(reader.readLine()); for(i = 0;i<c;i++){ String[] pq = reader.readLine().split(" "); int p = Integer.parseInt(pq[0]); int q = Integer.parseInt(pq[1]); int result = sums[q]-sums[p]+array[p]; System.out.println(result); } } }