Optimal Safety for Constrained Differential Inclusions using Nonsmooth Control Barrier Functions