An efficient algorithm for solving a maximization problem under linear and quadratic constraints