This is an interesting problem because airlines, subways, etc. often give a restriction on luggage as the maximum on the sum of height, width and depth. The problem then is to devise a container with the maximum volume that conforms to the restriction.
Let z = w - x - y; substitute z into f(x,y,z) to get a function of x and y and a (fixed) parameter w. Then find its partial derivatives. Equating the derivatives to zero has only one solution where x and y are not zero.