https://medium.com/ccclub/ccclub-python-for-beginners-tutorial-613b2fdf38bf
cc 集團推出計程車服務 ccTAXI 服務,費用計算方式如下: p1 * 移動總距離 + p2 * 四個方向(東西南北)的單次最大移動距離加總 (詳細說明請見 hint)給定計費參數 p1、p2、乘客上車的位置,以及計程車行駛的路徑,請計算 1.下車的座標 2.該趟的車資輸入的第一行為計費參數(p1 p2) 輸入的第二行為初始位置(x y) 輸入的第三行開始為路徑,若為 "N" 在 y 軸方向增加,"E" 則在 x 軸方向增加,以此類推 輸入的最後一行為 "0",代表路程結束
#輸入兩種計費參數
pric1, pric2 = [int(i) for i in input().split()]
#輸入起始座標
x, y = [int(i) for i in input().split()]
#東西南北個別最大移動距離
max_nsew = {'N': 0, 'S': 0, 'E': 0, 'W': 0}
#東西南北移動方式
nsew = {'N': [0, 1], 'S': [0, -1], 'E': [1, 0], 'W':[-1, 0]}
inp = input()
total_dis = 0
while inp[0] != '0':
inp = inp.split()
direct = inp[0]
dis = int(inp[1])
#更新該方向最大移動距離
if dis > max_nsew[direct]:
max_nsew[direct] = dis
#更新總距離
total_dis += dis
#更新座標
x += nsew[direct][0] * dis
y += nsew[direct][1] * dis
inp = input()
print(x, y)
print(total_dis * pric1 + sum(max_nsew.values()) * pric2)