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

Envío 6592

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

  • Autor: bryancalisto
  • Fecha: 2022-08-18 01:45:22 UTC (Hace más de 1 año)
Caso # Resultado Tiempo Memoria
#1
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.006 s 2 KBi
#2
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.006 s 2 KBi
#3
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.007 s 2 KBi
#4
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.009 s 2 KBi
#5
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.007 s 2 KBi
#6
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.007 s 2 KBi
#7
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.005 s 2 KBi
#8
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.007 s 2 KBi
#9
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.013 s 21 KBi
#10
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.016 s 21 KBi
#11
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.012 s 21 KBi
#12
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.008 s 11 KBi
#13
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.013 s 21 KBi
#14
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.021 s 21 KBi
#15
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.006 s 2 KBi
Puntos totales: 0 / 100

Código

#include <bits/stdc++.h>

using namespace std;

int main()
{
  int N;
  vector<int> monedas;
  int M;
  int nValores = 10001;

  std::cin >> N;
  for (int i = 0; i < N; i++)
  {
    int mon;
    std::cin >> mon;
    monedas.push_back(mon);
  }

  vector<vector<int>> tbl(nValores, vector<int>(N));
  std::cin >> M;
  int valor;

  for (int i = 0; i < nValores; i++)
  {
    tbl[nValores][0] = 1;
  }

  for (int i = 0; i < nValores; i++)
  {
    for (int j = 0; j < N; j++)
    {
      if (j > 0)
      {
        tbl[i][j] = tbl[i][j - 1];
      }

      int restante = i - tbl[i][j - 1];

      if (restante > 0)
      {
        tbl[i][j] = (tbl[i][j] + tbl[restante][j]) % 1000000007;
      }
    }
  }

  for (int i = 0; i < M; i++)
  {
    std::cin >> valor;
    std::cout << tbl[valor][N - 1];
  }

  return 0;
}