A class of degenerate elliptic equations and a Dido's problem with respect to a measure