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

Envío 2426

Problema 0x25 - Suma de un subarreglo grande

  • Autor: stivenxito
  • Fecha: 2020-12-18 03:37:30 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Incorrecto
0.153 s 16 KBi
#2
Correcto
0.149 s 15 KBi
#3
Correcto
0.148 s 16 KBi
#4
Correcto
0.148 s 16 KBi
#5
Incorrecto
0.165 s 15 KBi
#6
Incorrecto
0.194 s 16 KBi
#7
Incorrecto
0.178 s 16 KBi
#8
Tiempo límite excedido
1.053 s 28 KBi
#9
Tiempo límite excedido
1.05 s 49 KBi
#10
Tiempo límite excedido
1.094 s 55 KBi
#11
Tiempo límite excedido
1.081 s 48 KBi
#12
Tiempo límite excedido
1.05 s 51 KBi
#13
Tiempo límite excedido
1.065 s 54 KBi
#14
Tiempo límite excedido
1.03 s 58 KBi
Puntos totales: 22 / 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:arr){
 arr[i] = scan.nextInt();
}

int c = scan.nextInt();

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

}

}

}