Answer:
A is denser than B as it's volume for the same mass is smaller.
Step-by-step explanation:
Hello.
In this case, we first need to take into account that the density of each metal A and B is computed by dividing the mass over the volume of each metal which is actually computed by substracting the volume of water from the volume of the water and the solid:

Next, we compute the densities as shown below:

In such a way, A is denser is B as it's volume for the same mass is smaller.
Best regards.