Quantum optical device accelerating dynamic programming