see the figure below to better understand the problem
The perimeter of the fence is equal to
2y+x=36 ------> x=36-2y -----> equation 1
The area is equal to
A=x*y -----> equation 2
substitute equation 1 in equation 2
A=(36-2y)*y
A=36y-2y^2 ----> quadratic equation
this quadratic equation represents a vertical parabola open downward
The vertex is a maximum
The y-coordinate of the vertex represents the maximum area
The x-coordinate of the vertex represents the dimension y of the pen for the maximum area
so
Find out the vertex of the parabola
Complete the square
The vertex of the parabola is (9,162)
so
y=9
Find out the value of x
equation 1
x=36-2y
x=36-2(9)
x=18
the dimensions are 9 m x 18 m
Verify the maximum area
A=9*18=162 m2 ----> is ok is equal to the y-coordinate of the vertex
the answer is 9 m x 18 m