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

Envío 505

Problema 0x25 - Suma de un subarreglo grande

  • Autor: davidtoca
  • Fecha: 2020-09-06 22:15:09 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.005 s 1 KBi
#2
Correcto
0.007 s 1 KBi
#3
Correcto
0.006 s 1 KBi
#4
Correcto
0.006 s 7 KBi
#5
Correcto
0.006 s 1 KBi
#6
Correcto
0.024 s 1 KBi
#7
Correcto
0.028 s 1 KBi
#8
Tiempo límite excedido
1.04 s 17 KBi
#9
Tiempo límite excedido
0.306 s 6 KBi
#10
Tiempo límite excedido
0.365 s 7 KBi
#11
Tiempo límite excedido
0.296 s 6 KBi
#12
Tiempo límite excedido
0.247 s 5 KBi
#13
Tiempo límite excedido
0.374 s 8 KBi
#14
Tiempo límite excedido
1.014 s 18 KBi
Puntos totales: 50 / 100

Código

#include <iostream>
#include <map>

using namespace std;

int main() {
  int len, c, q, p;
  cin >> len;

  int input[len];

  map<string, int> output;

  for(int i=0;i<len; i++){
    cin >> input[i];
    string key = to_string(i)+to_string(i);
    output[key] = input[i];
  }

  for(int i=0; i<len; i++){
    for(int j=i+1; j<len; j++){
      if(i == j){
        continue;
      }
      string key = to_string(i)+to_string(j);
      string prev_key = to_string(i)+to_string(j-1);
      string single_key = to_string(j)+to_string(j);

      output[key] = output[prev_key] + output[single_key];
      //cout << "["  << i <<"][" << j <<"]=[" << output[i][j]<<"]" << endl;
    }
  }
  cin >> c;

  for(int i=0; i<c;i++){
    cin >> q;
    cin >> p;
    string key = to_string(q)+to_string(p);
    cout << output[key] << endl;
  }

}