Milo’s directed treasure map has no cycles. Starting at node 1, find the maximum treasure obtainable along a path to node n. Input: n m; n node rewards; m directed edges u v. Output maximum path reward from 1 to n, or IMPOSSIBLE.
Example 1:
Example 2:
Example 3:
Constraints:
1≤n≤200000; m≤300000; rewards may be negative.
Tags:
