Always break down your problem into smaller, simpler steps and work your way up to the final solution.
Why don't you start by having a fixed number of cities (say 10) and a single salesman? Also hard-code the start (a) and end (b) cities (say, 2 and 7) and initial price (p) (say 5) for this salesman. Print out the price of the object at each city. You should get a printout something like this:
city price
1 0
2 5
3 6
4 7
5 8
6 9
7 10
8 0
9 0
10 0
|
Next, add a second salesman with differing a, b and p values. Put the a, b and p values into an array to make this expandable in the future. Now print out the calculated price for each salesman at each city, as well as the maximum price at each city.
So, for a1=2, b1=7, p1=5, a2=4, b2=9, p2=3 you would get a printout something like this:
city price1 price2 max
1 0 0 0
2 5 0 5
3 6 0 6
4 7 3 7
5 8 4 8
6 9 5 9
7 10 6 10
8 0 7 7
9 0 8 8
10 0 0 0
|
After you get this far you can worry about keeping track of the maximum city value and expanding to a million cities (wow, that's a long river) and 300,000 salesmen and initial prices of up to 2 billion (wow, think about the GDP for that country).
But get the basics working before you expand your code to implement the entire problem.