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

Envío 3198

Problema 0x25 - Suma de un subarreglo grande

  • Autor: DAHO
  • Fecha: 2021-02-27 19:18:16 UTC (Hace alrededor de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.006 s 1 KBi
#2
Correcto
0.005 s 1 KBi
#3
Correcto
0.005 s 2 KBi
#4
Correcto
0.006 s 2 KBi
#5
Correcto
0.007 s 1 KBi
#6
Correcto
0.006 s 1 KBi
#7
Correcto
0.005 s 2 KBi
#8
Correcto
0.461 s 2 KBi
#9
Tiempo límite excedido
1.071 s 2 KBi
#10
Tiempo límite excedido
1.019 s 1 KBi
#11
Tiempo límite excedido
1.064 s 1 KBi
#12
Tiempo límite excedido
1.052 s 2 KBi
#13
Correcto
0.268 s 2 KBi
#14
Tiempo límite excedido
1.048 s 2 KBi
Puntos totales: 65 / 100

Código

#include<iostream>
using namespace std;

int main(){
  long n,c,p,q;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++)cin>>arr[i];
  cin>>c;
  for(int i=0;i<c;i++){
  	cin>>p>>q;
    long answer = 0;
    for(int j=p;j<=q;j++)answer+=arr[j];
  	cout<<answer<<endl;
  }
}