I'm an engineer on a ship and while I don't work on a container ship, I took a cargo class in college. There are other considerations too, the software frequently accounts for things such as not putting chemicals that react poorly with each other near each other or things that may be hard to put out if they catch on fire near the top of stacks on the outside so they can be jettisoned in an emergency. Also, while no one weighs each container, its part of the process for people doing the shipping to say what is in it and how much it weighs. They can probably fudge the weight a little but the software takes into account the reported weight to make sure the ship has safe stability. Containers stored inside are dryer and less likely to be lost overboard which normally is a premium price for shipping too. Plus as you mentioned the logistics problem of not putting all the new stuff on top of stuff that gets taken off at an earlier port.