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

Envío 4825

Problema 0x25 - Suma de un subarreglo grande

  • Autor: josuedzp
  • Fecha: 2021-08-26 10:33:30 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Incorrecto
0.022 s 3 KBi
#2
Incorrecto
0.021 s 3 KBi
#3
Incorrecto
0.026 s 3 KBi
#4
Incorrecto
0.023 s 3 KBi
#5
Incorrecto
0.031 s 3 KBi
#6
Incorrecto
0.022 s 3 KBi
#7
Incorrecto
0.027 s 3 KBi
#8
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 24, in <module>
    main()
  File "script.py", line 21, in main
    solve(sum, p, q)
  File "script.py", line 2, in solve
    print(sum, p, q)
OSError: [Errno 27] File too large
0.123 s 8 KBi
#9
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 24, in <module>
    main()
  File "script.py", line 21, in main
    solve(sum, p, q)
  File "script.py", line 2, in solve
    print(sum, p, q)
OSError: [Errno 27] File too large
0.119 s 12 KBi
#10
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 24, in <module>
    main()
  File "script.py", line 21, in main
    solve(sum, p, q)
  File "script.py", line 2, in solve
    print(sum, p, q)
OSError: [Errno 27] File too large
0.127 s 12 KBi
#11
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 24, in <module>
    main()
  File "script.py", line 21, in main
    solve(sum, p, q)
  File "script.py", line 2, in solve
    print(sum, p, q)
OSError: [Errno 27] File too large
0.125 s 12 KBi
#12
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 24, in <module>
    main()
  File "script.py", line 21, in main
    solve(sum, p, q)
  File "script.py", line 2, in solve
    print(sum, p, q)
OSError: [Errno 27] File too large
0.139 s 14 KBi
#13
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 24, in <module>
    main()
  File "script.py", line 21, in main
    solve(sum, p, q)
  File "script.py", line 2, in solve
    print(sum, p, q)
OSError: [Errno 27] File too large
0.124 s 12 KBi
#14
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 24, in <module>
    main()
  File "script.py", line 21, in main
    solve(sum, p, q)
  File "script.py", line 2, in solve
    print(sum, p, q)
OSError: [Errno 27] File too large
0.116 s 12 KBi
Puntos totales: 0 / 100

Código

def solve(sum, p, q):
  print(sum, p, q)
  s = sum[q]
  if p - 1 >= 0:
    s -= sum[p-1]

  print(s)


def main():
  num_elements = int(input())
  elements = list(map(int, input().split(" ")))

  sum = [elements[0]]
  for i in range(1, len(elements)):
    sum.append(sum[i-1] + elements[i])

  num_queries = int(input())
  for _ in range(0, num_queries):
    p, q = list(map(int,input().split()))
    solve(sum, p, q)

if __name__ == "__main__":
  main()