you give functional graph it direct graph vertex go exactly arc the vertex numerate 0 n1graph give array f0f1fn1 fi number vertex go arc vertex besides give array weight arcs w0w1wn1 wi arc weight fi the graph sample test also give integer k length path need find vertex number si mi si sum weight arcs path length equal k starts vertex mi minimal weight arc path length k start vertex the length path number arc path