Demand correspondence is both upper and lower hemi-continuous; is the preference continuous?
I think that you should proceed by contradiction assume D is continuous, but $\succsim$ is not, then for a bundle either the more preferred than or the less preferred than sets are not closed. Choose the problematic set and choose a set B appropriately to get a contradiction of the existence of a maximum (remember that not closed sets might not admit a maximum), this will give you the desired contradiction. Once preferences are continuous, remains to check completeness of preferences to use the classic theorem that if preferences are complete, transitive and continuous, then a utility function representation exists.