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

Envío 975

Problema 0x25 - Suma de un subarreglo grande

  • Autor: juantamayo26
  • Fecha: 2020-10-05 06:54:12 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.005 s 3 KBi
#2
Correcto
0.005 s 4 KBi
#3
Correcto
0.005 s 1 KBi
#4
Correcto
0.006 s 1 KBi
#5
Correcto
0.005 s 1 KBi
#6
Correcto
0.006 s 1 KBi
#7
Correcto
0.006 s 1 KBi
#8
Correcto
0.256 s 2 KBi
#9
Tiempo límite excedido
0.536 s 1 KBi
#10
Tiempo límite excedido
0.822 s 1 KBi
#11
Tiempo límite excedido
0.518 s 5 KBi
#12
Tiempo límite excedido
0.587 s 2 KBi
#13
Correcto
0.139 s 3 KBi
#14
Tiempo límite excedido
0.591 s 1 KBi
Puntos totales: 65 / 100

Código

#include<iostream>
using namespace std;
int a[50001];

int main(){
  int n;
  cin>>n;
  for(int i=0; i<n; i++){
    cin>>a[i];
  }
  int c;
  cin>>c;
  while(c--){
    int x,b,ans=0;
    cin>>x>>b;
    for(int i=x; i<=b; i++){
      ans=a[i]+ans;
    }
    cout<<ans<<endl;
  }
  return 0;
}