The first line contains three space-separated integers: N (number of nodes), M (number of directed edges), and k (maximum number of moves).
The second line contains N space-separated integers, representing the values of nodes 0 to N-1.
The next M lines each contain two space-separated integers u and v, representing a directed edge from node u to node v.
Your function should return a single long integer representing the maximum possible total value. The runner code will handle printing.
This problem can be solved efficiently using dynamic programming. Let dp[i][j] be the maximum value of a path of exactly i moves ending at node j. The state transition would be:
dp[i][j] = value[j] + max(dp[i-1][p]) for all nodes p that have an edge leading to j.
The base case is dp[0][j] = value[j] for all j. The final answer will be the maximum value found anywhere in the dp table.
Count of Subsequences with Given Sum
Optimal Line Arrangement
Distinct Integers After Zero Removal
Maximize Partition Value
Minimum Cost to Connect Network