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

Envío 4281

Problema 0x25 - Suma de un subarreglo grande

  • Autor: arturor72
  • Fecha: 2021-06-05 00:20:19 UTC (Hace casi 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.119 s 13 KBi
#2
Correcto
0.152 s 16 KBi
#3
Correcto
0.155 s 12 KBi
#4
Correcto
0.109 s 14 KBi
#5
Correcto
0.124 s 13 KBi
#6
Correcto
0.184 s 15 KBi
#7
Correcto
0.157 s 13 KBi
#8
Correcto
0.967 s 46 KBi
#9
Tiempo límite excedido
1.191 s 53 KBi
#10
Tiempo límite excedido
1.026 s 49 KBi
#11
Tiempo límite excedido
1.072 s 47 KBi
#12
Tiempo límite excedido
1.112 s 50 KBi
#13
Tiempo límite excedido
1.076 s 92 KBi
#14
Tiempo límite excedido
1.085 s 57 KBi
Puntos totales: 58 / 100

Código

    import java.util.Scanner;                                                       
public class Main{                                               
    public static void main(String... args){                                    
        Scanner  sc=new  Scanner(System.in);                                    
        int n=sc.nextInt();                                                     
        int arr[]=new int[n];                                                   
        for(int i=0; i<n; i++){                                                 
            arr[i]=sc.nextInt();                                                
        }                                                                       
        int consulta=sc.nextInt();                                              
        for(int i=0; i<consulta; i++){                                          
            int p=sc.nextInt();                                                 
            int q=sc.nextInt();                                                 
            int c=0;                                                            
            for(int j=p; j<=q; j++) c+=arr[j];                                  
            System.out.println(c);                                              
        }                                                                       
        sc.close();                                                             
    }   
}