Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.146 s | 12 KBi |
#2 |
Correcto
|
0.147 s | 13 KBi |
#3 |
Correcto
|
0.169 s | 12 KBi |
#4 |
Correcto
|
0.139 s | 12 KBi |
#5 |
Correcto
|
0.18 s | 12 KBi |
#6 |
Correcto
|
0.173 s | 13 KBi |
#7 |
Correcto
|
0.198 s | 12 KBi |
#8 |
Tiempo límite excedido
|
0.254 s | 15 KBi |
#9 |
Correcto
|
0.773 s | 34 KBi |
#10 |
Tiempo límite excedido
|
0.857 s | 36 KBi |
#11 |
Correcto
|
0.696 s | 36 KBi |
#12 |
Tiempo límite excedido
|
0.288 s | 17 KBi |
#13 |
Correcto
|
0.725 s | 35 KBi |
#14 |
Correcto
|
0.803 s | 35 KBi |
import java.util.Scanner; public class Main { public static int[] processLine(int N, Scanner myObj) { int elements[] = new int[N]; for (int i=0; i < N; i++) { elements[i] = myObj.nextInt(); } return elements; } public static int sum(int[] elements, int from, int to) { int sum = 0; for (int i=from; i <= to; i++) { sum += elements[i]; } return sum; } public static void main(String ...args) { int N, C, from, to; int[] elements; Scanner myObj = new Scanner(System.in); N = myObj.nextInt(); elements = processLine(N, myObj); C = myObj.nextInt(); for (int i = 0; i < C; i++) { from = myObj.nextInt(); to = myObj.nextInt(); System.out.println(sum(elements, from, to)); } } }