Explain the logic behind a classic optimization puzzle involving resource allocation under constraints.