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

Envío 2467

Problema 0x25 - Suma de un subarreglo grande

  • Autor: stivenxito
  • Fecha: 2020-12-21 02:29:24 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.135 s 12 KBi
#2
Correcto
0.171 s 16 KBi
#3
Correcto
0.16 s 15 KBi
#4
Correcto
0.16 s 16 KBi
#5
Correcto
0.161 s 15 KBi
#6
Correcto
0.189 s 16 KBi
#7
Correcto
0.176 s 16 KBi
#8
Tiempo límite excedido
1.195 s 48 KBi
#9
Tiempo límite excedido
1.193 s 50 KBi
#10
Tiempo límite excedido
1.034 s 57 KBi
#11
Tiempo límite excedido
1.046 s 55 KBi
#12
Tiempo límite excedido
1.036 s 58 KBi
#13
Tiempo límite excedido
1.124 s 61 KBi
#14
Tiempo límite excedido
1.106 s 50 KBi
Puntos totales: 50 / 100

Código

import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);

    int n = scan.nextInt();
    int[] arr = new int[n];

    for(int i=0; i<n;i++){
    arr[i] = scan.nextInt();
    }

    int c = scan.nextInt();
    int x,a,b;
    for(int i=0; i<c; i++){
      x = 0 ;
      a = scan.nextInt();
      b = scan.nextInt();
      for(int j=a;j<=b;j++){
      x += arr[j];
      }
      System.out.println(x);
    }
    
 }
}