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

Envío 580

Problema 0x25 - Suma de un subarreglo grande

  • Autor: Mejibyte
  • Fecha: 2020-09-08 03:31:38 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.005 s 1 KBi
#2
Correcto
0.004 s 2 KBi
#3
Correcto
0.006 s 1 KBi
#4
Correcto
0.005 s 1 KBi
#5
Correcto
0.006 s 5 KBi
#6
Correcto
0.005 s 2 KBi
#7
Correcto
0.005 s 57 KBi
#8
Correcto
0.358 s 3 KBi
#9
Tiempo límite excedido
0.709 s 4 KBi
#10
Tiempo límite excedido
0.87 s 2 KBi
#11
Tiempo límite excedido
0.74 s 2 KBi
#12
Tiempo límite excedido
0.722 s 2 KBi
#13
Correcto
0.145 s 2 KBi
#14
Tiempo límite excedido
1.028 s 2 KBi
Puntos totales: 65 / 100

Código

#include <iostream>
#include <vector>
#include <cassert>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  assert(n > 0);


  int c;
  cin >> c;
  while (c--) {
    int p, q;
    cin >> p >> q;
    long long answer = 0;
    for (int i = p; i <= q; ++i) {
      answer += a[i];
    }
    cout << answer << endl;
  }

  return 0;
}