Minimizing Weighted Cost Algorithm