Optimal solvability for a nonlinear problem at critical growth