Calculate maximum punishment for solution