does anyone know what the equation would be to start doing this?

An offshore oil well, P is located in the ocean 5 km from the neearest point on the shore, A. A pipeline is to be built to take oil from P to a refinery that is 20 km along the straight shoreline from A. Cost to build pipline in water is 100 000 per km, and on land is 75 000 per km. What route is cheapest?

*

|\

|5 \ Root(x^2+25)

| \

|----\-------*-----

{ x }{ 20-x}

Right so i got the equation

C= 100 000(x^2+25)^1/2 + 75000 (20-x)

answer said 5.7

how did they get that