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

Envío 2471

Problema 0x25 - Suma de un subarreglo grande

  • Autor: stivenxito
  • Fecha: 2020-12-21 02:41:19 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.008 s 1 KBi
#2
Correcto
0.005 s 1 KBi
#3
Correcto
0.006 s 1 KBi
#4
Correcto
0.006 s 1 KBi
#5
Correcto
0.006 s 2 KBi
#6
Correcto
0.009 s 2 KBi
#7
Correcto
0.007 s 1 KBi
#8
Correcto
0.414 s 1 KBi
#9
Tiempo límite excedido
1.047 s 2 KBi
#10
Tiempo límite excedido
1.077 s 1 KBi
#11
Tiempo límite excedido
1.073 s 2 KBi
#12
Tiempo límite excedido
1.066 s 1 KBi
#13
Correcto
0.212 s 2 KBi
#14
Tiempo límite excedido
1.059 s 2 KBi
Puntos totales: 65 / 100

Código

#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;

  int arr[n];
  for(int i=0; i<n;i++){
    cin>>arr[i];
    }
  
  int c;
  cin >> c;

  int x,a,b;

for(int i=0; i<c; i++){
      x = 0 ;
      cin >> a;
      cin >> b;
      for(int j=a; j<=b; j++){
        x+=arr[j];
      }
      cout << x << "\n";
    }
}