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

Envío 908

Problema 0x25 - Suma de un subarreglo grande

  • Autor: yerminson
  • Fecha: 2020-09-28 01:37:21 UTC (Hace más 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.005 s 1 KBi
#5
Correcto
0.005 s 1 KBi
#6
Correcto
0.005 s 1 KBi
#7
Correcto
0.005 s 1 KBi
#8
Correcto
0.296 s 3 KBi
#9
Tiempo límite excedido
0.582 s 2 KBi
#10
Tiempo límite excedido
0.608 s 3 KBi
#11
Tiempo límite excedido
0.584 s 1 KBi
#12
Tiempo límite excedido
0.747 s 3 KBi
#13
Correcto
0.14 s 2 KBi
#14
Tiempo límite excedido
0.674 s 1 KBi
Puntos totales: 65 / 100

Código

#include <iostream>

using namespace std;

int main()
{
  int n;
  cin >> n;

  int values[n];

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

  int c;
  cin >> c;
  int p, q;
  for (int i = 0; i < c; i++)
  {
    cin >> p >> q;
    int total = 0;
    for (int j = p; j <= q; j++)
    {
      total += values[j];
    }
    cout << total << endl;
  }

  return 0;
}