You are given a directed weighted graph with n nodes labeled from 0 to n - 1.
The graph is represented by a 2D integer array edges, where edges[i] = [ui, vi, ti] indicates a directed edge from node ui to node vi that takes ti seconds to traverse.
You are also given an integer power representing the initial available power, and an integer array cost of length n, where cost[u] represents the power required to forward the signal from node u through any one of its outgoing edges.
You are given two integers source and target.
The signal starts at source at time 0 with power units of power and follows these rules:
u only if the remaining power is at least cost[u].u, the remaining power is decreased by cost[u] units.edges[i] = [ui, vi, ti] increases the total time by ti seconds.Return an integer array answer of size 2, where:
answer[0] is the minimum time required for the signal to reach node target.answer[1] is the maximum remaining power among all paths that achieve answer[0].If the signal cannot reach target, return [-1, -1].
Example 1:

Input: n = 5, edges = [[0,1,1],[1,4,1],[0,2,1],[2,3,1],[3,4,1]], power = 4, cost = [2,3,1,1,1], source = 0, target = 4
Output: [3,0]
Explanation:
0 -> 1 -> 4 is not valid, because after leaving node 0, the signal has 2 units of power remaining, which is less than cost[1] = 3.0 -> 2 -> 3 -> 4 takes a total time of 3.cost[0] + cost[2] + cost[3] = 4, leaving 0 remaining power.[3, 0].Example 2:

Input: n = 3, edges = [[0,1,2],[1,2,2],[2,0,2]], power = 3, cost = [1,1,1], source = 1, target = 1
Output: [0,3]
Explanation:
source and target are the same node, no traversal is required.[0, 3].Example 3:
Input: n = 4, edges = [[0,1,3],[2,3,4]], power = 3, cost = [1,1,1,1], source = 0, target = 3
Output: [-1,-1]
Explanation:
There is no valid path from source to target, therefore return [-1, -1].
Constraints:
1 <= n <= 10000 <= edges.length <= 1000edges[i] = [ui, vi, ti]0 <= ui, vi <= n - 11 <= ti <= 1091 <= power <= 1000cost.length == n1 <= cost[i] <= 20000 <= source, target <= n - 1Loading editor...
5 [[0,1,1],[1,4,1],[0,2,1],[2,3,1],[3,4,1]] 4 [2,3,1,1,1] 0 4