Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.162 s | 16 KBi |
#2 |
Correcto
|
0.195 s | 12 KBi |
#3 |
Correcto
|
0.162 s | 16 KBi |
#4 |
Correcto
|
0.185 s | 12 KBi |
#5 |
Correcto
|
0.193 s | 12 KBi |
#6 |
Correcto
|
0.211 s | 16 KBi |
#7 |
Correcto
|
0.234 s | 13 KBi |
#8 |
Tiempo límite excedido
|
1.052 s | 51 KBi |
#9 |
Tiempo límite excedido
|
1.021 s | 61 KBi |
#10 |
Tiempo límite excedido
|
1.099 s | 110 KBi |
#11 |
Tiempo límite excedido
|
1.102 s | 111 KBi |
#12 |
Tiempo límite excedido
|
1.132 s | 111 KBi |
#13 |
Tiempo límite excedido
|
1.164 s | 119 KBi |
#14 |
Tiempo límite excedido
|
1.137 s | 112 KBi |
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Data data = readNumsFromStdin(); for (Request request : data.request) { int sum = 0; for (int i = request.init; i <= request.end; i++) { sum += data.numbers[i]; } System.out.println(sum); } } private static Data readNumsFromStdin() { Data data = new Data(); Scanner in = new Scanner(System.in); data.totalNumbers = in.nextInt(); data.numbers = new int[data.totalNumbers]; readArrayFromStdin(data.numbers, data.totalNumbers, in); data.totalRequest = in.nextInt(); data.request = new Request[data.totalRequest]; readRequestArrayFromStdin(data.request, data.totalRequest, in); return data; } private static void readArrayFromStdin(int[] array, int count, Scanner in) { for (int i = 0; i < count; i++) { array[i] = in.nextInt(); } } private static void readRequestArrayFromStdin(Request[] array, int count, Scanner in) { for (int i = 0; i < count; i++) { array[i] = new Request(in.nextInt(), in.nextInt()); } } private static class Data { int totalNumbers; int[] numbers; int totalRequest; Request[] request; } private static class Request { int init; int end; public Request(int init, int end) { this.init = init; this.end = end; } } }