change mincost maxflow to dynamic programing with greedy choise