Density has no effect on gravity. Only the object's mass,
YOUR mass, and your distance from the center of the object.
Object-B has more mass than Object-A. Therefore, you weigh more
when you're 50 meters from Object-B than when you're the same
distance from Object-A.
Also notice that Object-B weighs more when it's 50 meters from you
than Object-A does when it's the same distance from you.