A fence is to be made to enclose three sides of a rectangular area beside a river. The river forms the fourth side of the enclosure. This fence costs $30/metre. The enclosure is divided in half by another fence at right angles to the river. This fence costs $20/metre. The area to be enclosed is 500m^2. Find the dimensions for minimum cost of fencing.

Please provide full solution. Thanks.