# SRM 400 DIV2 [250]

#include<iostream>
#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

 Class: GrabbingTaxi Method: minTime Parameters: vector , vector , int, int, int, int Returns: int Method signature: int minTime(vector tXs, vector tYs, int gX, int gY, int walkTime, int taxiTime) (be sure your method is public)

### 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)

 {} {} 3 2 10 2
Returns: 50
 There are no taxi stands. You have to walk to the goal.
1)

 {-2, -2} {0, -2} -4 -2 15 3
Returns: 42
 First, you walk to (-2, 0) and get a taxi. Then you go to the goal by it.
2)

 {3} {0} 5 0 10 20
Returns: 50
 taxiTime may be larger than walkTime.
3)

 {34, -12, 1, 0, 21, -43, -98, 11, 86, -31} {11, 5, -68, 69, -78, -49, -36, -2, 1, 70} -97 -39 47 13
Returns: 2476
4)

 {82, -60, 57, 98, 30, -67, 84, -42, -100, 62} {-7, 90, 53, -56, -15, -87, 22, -3, -61, -30} 21 15 53 2
Returns: 1908

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.

• 本文已收录于以下专栏：

举报原因： 您举报文章：SRM 400 DIV2 [250] 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)