From the given infomation, the cost for river Y is constant, that is,

where Y denotes the cost for river Y.
On the other hand, the cost for river Z is given by

where n denotes the number of hours and Z the cost for river Z.
Therefore, the Total cost (C) will be the sum of the cost for river Y and river Z, that is,

which gives
