Efficient algorithms to solve atom reconfiguration problems. I. Redistribution-reconfiguration algorithm