Orange Boy Can You Solve It Out? Ep.11

是时候放松一下,做一道简单的题目了

Walking

Orange Boy loves walking. One day, he wanna walk from (x_1,y_1) to (x_n,y_n)
the boy can walk in three types:

  1. from (x,y) to (x\pm1,y) by costing A yuan

  2. from (x,y) to (x,y\pm1) by costing B yuan

  3. from (x,y) to (x+1,y+1) or (x-1,y-1) by costing C yuan

He must walk from (x_1,y_1) to (x_2,y_2) then from (x_2,y_2) to (x_3,y_3) and so on and reaches (x_n,y_n)
What's the minimal cost???!!?!

Examples

Input
A,B,C=2,3,4
(1,1)->(3,3)->(2,2)->(4,3)
Output
18
Explain
Path is this:
(1,1) -> (2,2) -> (3,3) -> (2,2) -> (3,3) -> (4,3)
Cost=4+4+4+4+2=18
note that he must visit them in order.

Constriants

Subtask 1(100%): N \leq 10^6,0\leq A,B,C\leq 10^{18},0\leq x_i,y_i \leq 10^{18}

版权声明:
作者:XGN
链接:https://blog.hellholestudios.top/archives/185
来源:Hell Hole Studios Blog
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>