Suppose you move ft in the direction. The cost for this would be . Now the distance between you (now) and the point across the river is and the cost for this portion is and thus the total cost is

Now minimize C (i.e. and find l). Don't forget to check the endpoints (all river) and (all shore then across).