A simple criterion to design optimal non-pharmaceutical interventions for mitigating epidemic outbreaks