  We consider a discrete-time random walk on a line starting at $x_0\geq 0$
where a cost is incurred at each jump. We obtain an exact analytical formula
for the distribution of the total cost of a trajectory until the process
crosses the origin for the first time. The formula is valid for arbitrary jump
distribution and cost function (heavy- and light-tailed alike), provided they
are symmetric and continuous. We analyze the formula in different scaling
regimes, and find a high degree of universality with respect to the details of
the jump distribution and the cost function. Applications are given to the
motion of an active run-and-tumble particle in one dimension and extensions to
multiple cost variables are considered. The analytical results are in perfect
agreement with numerical simulations.
