Блог пользователя Arnob

Автор Arnob, история, 3 года назад, По-английски

Can someone help me with this problem

  • Проголосовать: нравится
  • +4
  • Проголосовать: не нравится

»
3 года назад, # |
Rev. 2   Проголосовать: нравится +7 Проголосовать: не нравится

Calculate $$$\textit{dp}(i, j)$$$ the minimum time to reach $$$a_i$$$ such that the bike is at position $$$j$$$ (prepend and append $$$0$$$ to array $$$a$$$ to make the implementation easier). To compute this $$$\textit{dp}$$$ array, consider transitions $$$\textit{dp}(i, j) \Rightarrow \textit{dp}(i + 1, j')$$$, meaning:

  1. Walk to $$$j$$$ and take bike
  2. Pedal to $$$j'$$$ leave bike there
  3. Walk to $$$a_{i + 1}$$$

Code