An optimality criterion for the crossing number