█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 2804

Problema 0x25 - Suma de un subarreglo grande

  • Autor: sancanella
  • Fecha: 2021-02-06 23:42:46 UTC (Hace alrededor de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.14 s 16 KBi
#2
Correcto
0.153 s 15 KBi
#3
Correcto
0.182 s 41 KBi
#4
Correcto
0.156 s 16 KBi
#5
Correcto
0.16 s 16 KBi
#6
Correcto
0.219 s 23 KBi
#7
Correcto
0.178 s 16 KBi
#8
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/openjdk13/bin/java Main
0.827 s 125 KBi
#9
Tiempo límite excedido
1.127 s 82 KBi
#10
Tiempo límite excedido
1.074 s 82 KBi
#11
Tiempo límite excedido
1.079 s 83 KBi
#12
Tiempo límite excedido
1.057 s 34 KBi
#13
Tiempo límite excedido
1.088 s 41 KBi
#14
Tiempo límite excedido
1.06 s 83 KBi
Puntos totales: 50 / 100

Código

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner teclado = new Scanner(System.in);
        teclado.nextLine();
        String[] entradas = teclado.nextLine().split(" ");
        int[] entint = new int[entradas.length];
        for (int i = 0; i < entradas.length; i++) {
            entint[i] = Integer.parseInt(entradas[i]);
        }
        
        int checks = Integer.parseInt(teclado.nextLine());
        for (int i = 0; i < checks; i++) {
            String[] par  = teclado.nextLine().split(" ");
            int a = Integer.parseInt(par[0]);
            int b = Integer.parseInt(par[1]);
            int sum = 0;
            for(int j = a; j <= b;j++){
                sum += entint[j];
            }
            
            System.out.println(sum);
        }
        
        
    }
}