solution to minimumTotal using quadratic space