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

Envío 6564

Problema 0xcb - Contar maneras de formar una cantidad con monedas

  • Autor: bryancalisto
  • Fecha: 2022-08-06 20:33:22 UTC (Hace más de 1 año)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.031 s 4 KBi
#2
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 24, in <module>
    print(tbl[valor][N - 1])
IndexError: list index out of range
0.034 s 4 KBi
#3
Correcto
0.019 s 3 KBi
#4
Correcto
0.029 s 3 KBi
#5
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 24, in <module>
    print(tbl[valor][N - 1])
IndexError: list index out of range
0.042 s 3 KBi
#6
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 24, in <module>
    print(tbl[valor][N - 1])
IndexError: list index out of range
0.056 s 4 KBi
#7
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 24, in <module>
    print(tbl[valor][N - 1])
IndexError: list index out of range
0.049 s 4 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>
    print(tbl[valor][N - 1])
IndexError: list index out of range
0.044 s 4 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>
    print(tbl[valor][N - 1])
IndexError: list index out of range
0.801 s 23 KBi
#10
Tiempo límite excedido
1.579 s 84 KBi
#11
Tiempo límite excedido
1.594 s 94 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>
    print(tbl[valor][N - 1])
IndexError: list index out of range
0.785 s 49 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>
    print(tbl[valor][N - 1])
IndexError: list index out of range
0.769 s 23 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>
    print(tbl[valor][N - 1])
IndexError: list index out of range
1.297 s 59 KBi
#15
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 24, in <module>
    print(tbl[valor][N - 1])
IndexError: list index out of range
0.04 s 4 KBi
Puntos totales: 20 / 100

Código

N = int(input())
monedas = list(map(int, input().split(' ')))
M = int(input())
nValores = 5001  # Segun constraint de maximo valor y +1 porque incluye el 0

tbl = [[0 for i in range(N)] for j in range(nValores)]

for iMoneda in range(N):  # Si tienes un valor de 0 (fila 0), necesitas solo un set para representar ese valor: {}
    tbl[0][iMoneda] = 1

for valor in range(nValores):
    for iMoneda in range(N):
        if iMoneda > 0:
            tbl[valor][iMoneda] = tbl[valor][iMoneda-1]

        restante = valor - monedas[iMoneda]

        if restante >= 0:
            tbl[valor][iMoneda] = (tbl[valor][iMoneda] + tbl[restante][iMoneda]) % 1000000007


for i in range(M):
    valor = int(input())
    print(tbl[valor][N - 1])