Chemical formula of a compound crystallized in a cubic lattice
I would like to say your answer is right, but the question is wrong. 

Remember that a lattice is "infinitely" repeated units in 3 dimensional space so you should be able to expand the unit cell in x, y and z axes, indefinitely.

Now imagine your cubic lattice with an $\ce{Y}$ atom in just 1 (out of 8) corners. 

Expanding the unit cell in the x-axis will necessarily duplicate the $\ce{Y}$ atom in the x-axis because all expanded unit cells must be identical in composition. Similarly, expanding the unit cell in the y-axis will duplicate the $\ce{Y}$ atom in the y-axis, and expanding the unit cell in the z-axis will duplicate the $\ce{Y}$ atom in the z-axis. 

In the end you will find the having one corner as $\ce{Y}$ atom will necessarily have ALL corners as $\ce{Y}$ atoms. In other words, $\ce{X}$ IS $\ce{Y}$, and the formula is necessarily $\ce{XZ_3}$ or $\ce{YZ_3}$

Unfortunately, I don'k think the designer of the question saw his fatal contradiction because this very question is seen in the (mock) Joint Entrance Examination (JEE) in India.

  

And $\ce{X_2YZ_24}$ is not in the options even in the wrong question.