#include < vector >
#include < cmath >
using namespace std;
class GrabbingTaxi ... {
public:
int minTime(vector <int> tXs, vector <int> tYs, int gX, int gY, int walkTime, int taxiTime)
...{
int ans=(abs(gX)+abs(gY))*walkTime;
for (int i=0;i!=tXs.size();++i)
if (walkTime*(abs(tXs[i])+abs(tYs[i]))+taxiTime*(abs(gX-tXs[i])+abs(gY-tYs[i]))<ans)
ans=walkTime*(abs(tXs[i])+abs(tYs[i]))+taxiTime*(abs(gX-tXs[i])+abs(gY-tYs[i]));
return ans;
}
} ;
Problem Statement | |||||||||||||
You are walking in the city on a holiday. Suddenly, you are told to go to your office as soon as possible by your boss via cell phone. The city is infinite in size, with vertical streets located at every integer X value and horizontal streets located at every Y value. You are currently located at (0, 0) and your office is located at (gX, gY). There are some taxi stands in the city and their locations are (tXs[i], tYs[i]). You can either go to the office by foot or go to some taxi stand, get a taxi there and go to the office by taxi. It takes walkTime seconds to go along the street to proceed to a horizontally or vertically adjacent intersection by foot and it takes taxiTime seconds by a taxi. Return the least amount of time that it will take you to go to your office. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | tXs will contain between 0 and 50 elements, inclusive. | ||||||||||||
- | tXs and tYs will contain the same number of elements. | ||||||||||||
- | Each element of tXs and tYs will be between -10000 and 10000, inclusive. | ||||||||||||
- | gX and gY will be between -10000 and 10000, inclusive. | ||||||||||||
- | walkTime and taxiTime will be between 1 and 1000, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
|
This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.