The longest shortest fence and sharp Poincaré-Sobolev inequalities