Optimization algorithm for reentrant scheduling in block painting operations