Domain in optimization problem

#11. There are $320 available to fence in rectangular garden. The fencing for the side of the garden facing the road costs $6 per foot and the fencing for the other three sides costs $2 per foot. Consider the problem of finding the dimensions of the largest possible garden.

So I solved everything and got:

A=xy as the objective equation

C=8y+4x=320 as the constraint equation

A=(80x-x^2)/2

A'=(80-2x)/2 then I set that to zero and got x=40, y=20.

How come the correct answer is x=20 y=40? More importantly, how do you get the domain? (which is 0<x<40)

* i realized that I set C=8y+4x=320 while the answer key has C=8x+4y=320* Would my answer be still correct?