Deepak and journey problem...please tell what is wrong in this code
The approach you are using is not correct. Basically, first you have to take two input arrays, and then you need to determine the total minimum cost. For that you can take two variables, one variable as cost_min and other as cost_total that will be initialised as :
cost_min = cost[0];
cost_total=cost_min*dist[0];
And then you need to determine the minimum cost… and then add it to the total cost value…
for(int i=1; i<stops; i++)
{
cost_min = min(cost[i], cost_min);
cost_total += (cost_min*dist[i]);
}
cout<<cost_total<<endl;