Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.094 s | 10 KBi |
#2 |
Correcto
|
0.075 s | 13 KBi |
#3 |
Correcto
|
0.089 s | 13 KBi |
#4 |
Correcto
|
0.076 s | 13 KBi |
#5 |
Correcto
|
0.088 s | 13 KBi |
#6 |
Correcto
|
0.072 s | 14 KBi |
#7 |
Correcto
|
0.097 s | 13 KBi |
#8 |
Correcto
|
0.871 s | 18 KBi |
#9 |
Tiempo límite excedido
|
1.051 s | 19 KBi |
#10 |
Tiempo límite excedido
|
1.053 s | 28 KBi |
#11 |
Tiempo límite excedido
|
1.075 s | 24 KBi |
#12 |
Tiempo límite excedido
|
1.037 s | 25 KBi |
#13 |
Correcto
|
0.588 s | 37 KBi |
#14 |
Tiempo límite excedido
|
1.078 s | 20 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()); 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()); int total = 0; for(;p<=q;p++) total+= values[p]; sb.append(total).append("\n"); } System.out.print(new String(sb).trim()); } } }