The density/mass of the cubes may be different. I believe it was Archimedes who discovered that for an object to float, it must displace it's own mass worth of water. That is, a 1kg sphere would need to displace 1kg of water to float. If it can't do that, it sinks.