Elliptic variational problems with critical exponent