You can solve your problem in linear time w.r.t. the size of your graph $G$.

Start by computing, in $O(n+m)$ time, the strongly connected components $C_1, C_2, dots, C_h$ of $G$.

Next, construct a new graph $G’ = (V’, E’)$ from $G$ by identifying each strongly connected component $C_i$ into single vertex $v$ having $k(v) = sum_{j in C_j} k_j$ coins. Then, compute a topological order $v_1, v_2, dots, v_h$ of the vertices in $G’$. This requires time $O(h + |E’|) = O(n+m)$.

Consider the vertices in reverse topological order and compute, for each vertex $v_i$, the maximum number of coins $eta(v_i)$ that can be collected starting from $v_i$. This can be done as follows: if $v_i$ has no outoging edges in $G’$ then $eta(v_i) = k(v_i)$, otherwise:

$$

eta(v_i) = k(v_i) + max_{(v_i, v_j) in E’} eta(v_j).

$$

This requires time proportional to the number $delta(v_i)$ of outgoing edges of $v_i$. The overall time required to compute all values $eta(v_i)$ is then $Oleft(h + sum_{i=1}^{h} delta(v_i) right) = O(h + |E’|) = O(n + m)$.

Finally, return $max_{i = 1, dots, h} eta(v_i)$.