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

Envío 2448

Problema 0x25 - Suma de un subarreglo grande

  • Autor: wesly
  • Fecha: 2020-12-19 01:47:16 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.158 s 16 KBi
#2
Correcto
0.165 s 16 KBi
#3
Correcto
0.139 s 52 KBi
#4
Correcto
0.153 s 15 KBi
#5
Correcto
0.149 s 15 KBi
#6
Correcto
0.187 s 16 KBi
#7
Correcto
0.186 s 16 KBi
#8
Tiempo límite excedido
1.04 s 37 KBi
#9
Tiempo límite excedido
1.032 s 92 KBi
#10
Tiempo límite excedido
1.064 s 48 KBi
#11
Tiempo límite excedido
1.046 s 58 KBi
#12
Tiempo límite excedido
1.092 s 49 KBi
#13
Tiempo límite excedido
1.058 s 55 KBi
#14
Tiempo límite excedido
1.094 s 54 KBi
Puntos totales: 50 / 100

Código

import java.util.Scanner;

/**
 *
 * @author usuario
 */
public class Main {

    public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int arraySize = sc.nextInt();
        int[] array = new int[arraySize];
        
        for(int i=0; i<arraySize; i++){
            int item = sc.nextInt();
            array[i] = item;
        }
        
        int querySize = sc.nextInt();
        int[] queries = new int[querySize];
        int[] result = new int[querySize];
        
        for(int i=0; i<querySize; i++){
            int one = sc.nextInt();
            int two = sc.nextInt();
            int temp = 0;
            for(int j=one; j<=two; j++){
                int item = array[j];
                temp+=item;
            }
            result[i] = temp;
        }
        
        for(int i=0; i<result.length; i++){
            System.out.println(result[i]);
        }
        
    }
}