Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.089 s | 13 KBi |
#2 |
Correcto
|
0.09 s | 25 KBi |
#3 |
Correcto
|
0.084 s | 13 KBi |
#4 |
Correcto
|
0.089 s | 14 KBi |
#5 |
Correcto
|
0.093 s | 17 KBi |
#6 |
Correcto
|
0.099 s | 23 KBi |
#7 |
Correcto
|
0.092 s | 13 KBi |
#8 |
Correcto
|
0.251 s | 21 KBi |
#9 |
Correcto
|
0.555 s | 37 KBi |
#10 |
Correcto
|
0.575 s | 35 KBi |
#11 |
Correcto
|
0.556 s | 34 KBi |
#12 |
Correcto
|
0.557 s | 34 KBi |
#13 |
Correcto
|
0.629 s | 37 KBi |
#14 |
Correcto
|
0.497 s | 37 KBi |
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws Throwable { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); for(String ln; (ln = in.readLine())!= null;){ int N = Integer.parseInt(ln); StringTokenizer st = new StringTokenizer(in.readLine()); StringBuilder sb = new StringBuilder(); int[] values = new int[N]; for(int i=0; i<N; i++) values[i] = Integer.parseInt(st.nextToken()); for(int i=1; i<N; i++) values[i]+= values[i-1]; int Q = Integer.parseInt(in.readLine()); while(Q-->0){ st = new StringTokenizer(in.readLine()); int p = Integer.parseInt(st.nextToken()); int q = Integer.parseInt(st.nextToken()); sb.append(values[q] - (p-1>=0?values[p-1]:0)).append("\n"); } System.out.print(new String(sb).trim()); } } }