Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.19 s | 24 KBi |
#2 |
Correcto
|
0.185 s | 18 KBi |
#3 |
Correcto
|
0.168 s | 16 KBi |
#4 |
Correcto
|
0.19 s | 16 KBi |
#5 |
Correcto
|
0.191 s | 21 KBi |
#6 |
Correcto
|
0.195 s | 16 KBi |
#7 |
Correcto
|
0.228 s | 26 KBi |
#8 |
Tiempo límite excedido
|
1.016 s | 48 KBi |
#9 |
Tiempo límite excedido
|
1.031 s | 80 KBi |
#10 |
Tiempo límite excedido
|
1.066 s | 109 KBi |
#11 |
Tiempo límite excedido
|
1.064 s | 119 KBi |
#12 |
Tiempo límite excedido
|
1.07 s | 119 KBi |
#13 |
Tiempo límite excedido
|
1.025 s | 111 KBi |
#14 |
Tiempo límite excedido
|
1.05 s | 111 KBi |
import java.util.Scanner; public class Main { public static void main(String[] args) { Data data = readNumsFromStdin(); int[] results = new int[data.totalRequest]; for (int i = 0; i < data.totalNumbers; i++) { for (int j = 0; j < data.totalRequest; j++) { if (i >= data.request[j].init && i <= data.request[j].end) { results[j] += data.numbers[i]; } } } for (int result : results) { System.out.println(result); } } 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; } } }