You are given an integer n representing the number of vertices in a directed acyclic graph, labeled from n edges, where edges[i] = [u_i, v_i, w_i] denotes a directed edge from vertex u_i to vertex v_i with weight w_i.
Additionally, you are given two integers k and t.
Find the maximum possible sum of edge weights for any path in the graph that contains exactly k edges such that the total sum of weights is strictly less than t.
Return the maximum sum of weights among all valid paths. If no such path exists, return $-1$.
Constraints:
n
edges.length
edges[i] = [u_i, v_i, w_i]
u_i, v_i n
u_i v_i
w_i
k
t
The input graph is guaranteed to be a DAG.
There are no duplicate edges.
You are given an integer n representing the number of vertices in a directed acyclic graph, labeled from n edges, where edges[i] = [u_i, v_i, w_i] denotes a directed edge from vertex u_i to vertex v_i with weight w_i.
Additionally, you are given two integers k and t.
Find the maximum possible sum of edge weights for any path in the graph that contains exactly k edges such that the total sum of weights is strictly less than t.
Return the maximum sum of weights among all valid paths. If no such path exists, return $-1$.
Constraints:
n
edges.length
edges[i] = [u_i, v_i, w_i]
u_i, v_i n
u_i v_i
w_i
k
t
The input graph is guaranteed to be a DAG.
There are no duplicate edges.