• + 4 comments

    Don't do integer programming people, this task can be solved using simple graph theory in 50 lines of code.

    Hint: there exists a graph, in which the given question is equivalent to finding the shortest path from 0 to n.