Python3 implementation of the approach
import numpy as np NEW_LINE import sys NEW_LINE N = 100 NEW_LINE INT_MIN = - ( sys . maxsize - 1 ) NEW_LINE dp = np . zeros ( ( N , 3 ) ) ; NEW_LINE v = np . zeros ( ( N , 3 ) ) ; NEW_LINE