Rejection sampling from shape-constrained distributions in sublinear time