find the mincost route

HDU - 1599