We show that in the K-sat model with N variables and αN clauses, the expected ratio of the smallest number of unsatisfied clauses to the number of variables is α/2K−αc∗(N)/2K up to smaller order terms o(α) as α→∞ uniformly in N, where c∗(N) is the expected normalized maximum energy of some specific mixed p-spin spin glass model. The formula for the limit of c∗(N) is well known in the theory of spin glasses.