Problem:
 Score : 500 points    Problem Statement There are N towns on a line running east-west.
The towns are numbered 1 through N , in order from west to east.
Each point on the line has a one-dimensional coordinate, and a point that is farther east has a greater coordinate value.
The coordinate of town i is X_i .  You are now at town 1 , and you want to visit all the other towns.
You have two ways to travel:    Walk on the line.
Your fatigue level increases by A each time you travel a distance of 1 , regardless of direction.    Teleport to any location of your choice.
Your fatigue level increases by B , regardless of the distance covered.    Find the minimum possible total increase of your fatigue level when you visit all the towns in these two ways.      Constraints  All input values are integers.  2≤N≤10^5  1≤X_i≤10^9  For all i(1≤i≤N-1) , X_i<X_{i+1} .  1≤A≤10^9  1≤B≤10^9         Input The input is given from Standard Input in the following format:  N  A  B  X_1  X_2  ...  X_N       Output Print the minimum possible total increase of your fatigue level when you visit all the towns.        Sample Input 1 4 2 5
1 2 5 7      Sample Output 1 11  From town 1 , walk a distance of 1 to town 2 , then teleport to town 3 , then walk a distance of 2 to town 4 .
The total increase of your fatigue level in this case is 2×1+5+2×2=11 , which is the minimum possible value.       Sample Input 2 7 1 100
40 43 45 105 108 115 124      Sample Output 2 84  From town 1 , walk all the way to town 7 .
The total increase of your fatigue level in this case is 84 , which is the minimum possible value.       Sample Input 3 7 1 2
24 35 40 68 72 99 103      Sample Output 3 12  Visit all the towns in any order by teleporting six times.
The total increase of your fatigue level in this case is 12 , which is the minimum possible value.

Solution (Python):
N, A, B = map(int, input().split())
X = [int(x) for x in input().split()]

ans = 0
for i in range(N - 1):
    a = (X[i + 1] - X[i]) * A
    ans += min(a, B)
print(ans)

Solution (Python):


N,A,B=map(int,input().split())
X=list(map(int,input().split()))

start=X[0]
cost=0
for i in range(len(X)):
    goto=X[i]
    if((goto-start)*A>B):
        cost+=B
    else:
        cost+=(goto-start)*A
    start=goto

print(cost)

Solution (Python):
N,A,B = map(int,input().split())
X = list(map(int,input().split()))

Ans = 0
for i in range(1,N):
    if (X[i]-X[i-1])*A >= B:
        Ans += B
    else:
        Ans += (X[i]-X[i-1])*A

print(Ans)

Solution (Python):
n,a,b=map(int, input().split())
x=list(map(int, input().split()))
count=0
for i in range(1,n):
    if (x[i]-x[i-1])*a < b :count+=(x[i]-x[i-1])*a
    else: count+=b
    
print(count)

Solution (Python):
N, A, B = map(int, input().split())
X = list(map(int, input().split()))
ans = 0
for i in range(N-1):
    ans += min(A*(X[i+1]-X[i]), B)
print(ans)

Solution (Python):
N,A,B = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
for i in range(1,N):
  if (a[i] - a[i-1])*A < B:
    ans += (a[i] - a[i-1])*A
  else:
    ans += B
print(ans)

Solution (Python):
N,A,B = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
for i in range(1,N):
  if (a[i] - a[i-1])*A < B:
    ans += (a[i] - a[i-1])*A
  else:
    ans += B
print(ans)

Solution (Python):
n, a, b = map(int, input().split())
x = [int(x) for x in input().split()]
c = 0
for i in range(n - 1): c += min((x[i + 1] - x[i]) * a, b)
print(c)

Solution (Python):
n, a, b = map(int,input().split())
x = list(map(int,input().split()))

ans = 0
for i in range(n-1):
    ans += min(b, a*(x[i+1]-x[i]))

print(ans)

Solution (Python):
n, a, b = map(int, input().split())
l = list(map(int, input().split()))
ans = 0

for i in range(len(l) - 1):
  ans += min((l[i + 1]-l[i]) * a, b)

print(ans)

Solution (Python):
n, a, b = map(int,input().split())
cities = list(map(int,input().split()))
ans = 0

for i in range(1, n):
    if (cities[i] - cities[i-1]) * a >= b:
        ans += b
    else:
        ans += (cities[i] - cities[i-1]) * a

print(ans)

Solution (Python):
N, A, B = map(int, input().split(' '))
x_list = list(map(int, input().split(' ')))
ex = 0
for i in range(1, len(x_list)):
    if (x_list[i] - x_list[i-1]) * A >= B:
        ex += B
    else:
        ex += (x_list[i] - x_list[i-1]) * A
print(ex)

Solution (Python):
n, a, b = list(map(int, input().split()))
x = list(map(int, input().split()))
ans = 0

for i in range(n - 1):
    if (x[i + 1] - x[i]) * a >= b:
        ans += b
    else:
        ans += (x[i + 1] - x[i]) * a
        
print(ans)

Solution (Python):
N, A, B = map(int, input().split())
X = list(map(int, input().split()))
ans = sum([min(A * (X[i+1]-X[i]), B) for i in range(N-1)])
print(ans)

Solution (Python):
n, a, b = list(map(lambda x: int(x), input().split(" ")))
x = list(map(lambda x: int(x), input().split(" ")))

cost = 0
px = x[0]
for i in range(1, len(x)):
    w_cost = (x[i] - px) * a
    if w_cost > b:
        cost += b
    else:
        cost += w_cost
    px = x[i]

print(cost)

Solution (Python):
n,a,b = map(int, input().split(" "))
x = input().split(" ")
sum = 0
for i in range(n):
    x[i] = int(x[i])
for i in range(n-1):
    if a*(x[i+1]-x[i]) > b:
        sum += b
    else:
        sum += a*(x[i+1]-x[i])
print(sum)

Solution (Python):
n,a,b = map(int,input().split())
x = list(map(int,input().split()))
ans = 0
d = 0
for i in range(1,n):
    d = x[i]-x[i-1]
    ans += min(d*a, b)
print(ans)

Solution (Python):
n,a,b = (int(i) for i in input().split())
x = [int(i) for i in input().split()]
answer = 0
for i in range(n-1):
	if (x[i+1]-x[i])*a < b: answer += (x[i+1]-x[i])*a
	else: answer += b
print(answer)

Solution (Python):
n, a, b = map(int, input().split())
x = list(map(int, input().split()))
ans = 0
d = b/a
for j in range(n-1):
    o = x[j+1] - x[j]
    if o > d:
        ans += b
    else:
        ans += o * a
print(ans)

Solution (Python):
N,A,B=map(int,raw_input().split())
X=map(int,raw_input().split())
cost={}
for i in range(N-1):
		cost[(i,i+1)]=min(B, (X[i+1]-X[i])*A)

print sum( cost.values() )

Solution (Python):
N,A,B=map(int,input().split())
M=[int(x) for x in input().split()]

ans=0
for i in range(1,N):
  ans+=min(A*(M[i]-M[i-1]),B)
print(ans)

Solution (Python):
n, a, b = map(int,input().split())
lis = list(map(int,input().split()))
ans = 0
for i in range(n-1):
    if (lis[i + 1] -lis[i]) * a <= b:
        ans += (lis[i + 1] -lis[i]) * a
    else:
        ans += b
print(ans)

Solution (Python):
N,A,B = map(int,input().split(" "))
X = list(map(int,input().split(" ")))

ans = 0
for i in range(N-1):
	ans += min((X[i+1]-X[i])*A,B)

print(ans)

Solution (Python):
N,A,B = [int(i) for i in input().split()]
X = [int(i) for i in input().split()]

ans = 0
for i in range(N-1):
  ans += min(A*(X[i+1]-X[i]), B)
print(ans)

Solution (Python):
N, A, B = map(int, input().split())
X = list(map(int, input().split()))
ans = 0
for i in range(N-1):
    ans += min((A * (X[i+1]-X[i]), B))
print(ans)

Solution (Python):
l = map(int, raw_input().split())
points = map(int, raw_input().split())
cor = 0
for i in range(1,len(points)):
    if ((points[i]-points[i-1])*l[1]) > l[2]:
        cor+=l[2]
    elif ( (points[i]-points[i-1])*l[1])< l[2]:
        cor+=(points[i]-points[i-1])*l[1]

print cor

Solution (Python):
N,A,B=map(int, input().split())
X=list(map(int, input().split()))
ans=0
for i in range(N-1):
 if ((X[i+1]-X[i])*A<=B):
  ans+=(X[i+1]-X[i])*A
 else:
  ans+=B
print(ans)

Solution (Python):
n,a,b=[int(x) for x in input().split()]
x=[int(x) for x in input().split()]
ans=0
for i in range(n-1):
    ans+=min(a*(x[i+1]-x[i]),b)
print(ans)

Solution (Python):
read = lambda: map(int, input().split())
n, a, b = read()
x = list(read())
ans = 0
for i in range(1, n):
    cur = x[i] - x[i - 1]
    ans += min(b, cur * a)
print(ans)

Solution (Python):
from collections import defaultdict


def main():
    N, A, B = map(int, input().split())
    x_list = list(map(int, input().split()))

    ans = 0
    for i in range(len(x_list) - 1):
        d = x_list[i + 1] - x_list[i]
        ans += min(d * A, B)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):


n,a,b = map(int, raw_input().split())
x = map(int, raw_input().split())
y = [0]*(n-1)
ans = 0

for i in range(n-1):
    y[i] = x[i+1]-x[i]
for i in range(n-1):
    tmp = a*y[i]
    ans += tmp if tmp<b else b
print(ans)

Solution (Python):
import sys




def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    n, a, b = read_int_list()
    x = read_int_list()
    res = 0
    for i in range(1, n):
        d = x[i] - x[i - 1]
        effort = min(a * d, b)
        res += effort
    print(res)


main()

Solution (Python):
N,A,B = map(int, raw_input().split())
TOWNS = map(int, raw_input().split())
dists = [TOWNS[i+1] - TOWNS[i] for i in range(N-1)]
sum = 0
for dist in dists:
  sum += min(dist*A, B)
print sum

Solution (Python):
N, A, B = map(int, raw_input().split())
X = map(int, raw_input().split())
ans = 0
for i in range(N-1):
    if (X[i+1] - X[i]) * A < B:
        ans += (X[i+1] - X[i]) * A
    else:
        ans += B
print ans

Solution (Python):
n, a, b = [int(x) for x in input().split(' ')]
dis = [a*int(x) for x in input().split(' ')]
dist = [dis[x+1] - dis[x] for x in range(n-1)]
out = 0
for j in dist:
    if j > b:
        out += b
    else:
        out += j
print(out)

Solution (Python):
N,A,B=map(int, input().split())
X=list(map(int, input().split()))
judge=int(B/A)
cost=0
for i in range(N-1):
  if X[i+1]-X[i]<=judge:
    cost+=A*(X[i+1]-X[i])
  else:
    cost+=B

print(cost)

Solution (Python):
from collections import defaultdict


def main():
    N, A, B = map(int, input().split())
    X_list = list(map(int, input().split()))

    ans = 0
    for i in range(len(X_list) - 1):
        d = abs(X_list[i] - X_list[i + 1])
        ans += min(A * d, B)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys

INF = 1000000007

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()
def ni(): return int(stdin.readline())

n, a, b = na()
x = list(na())

ans = 0

for i in range(len(x) - 1):
    ans = ans + min((x[i+1] - x[i]) * a, b)

print(ans)

Solution (Python):



n, a, b = map(int, input().split())
x = list(map(int, input().split()))

c = 0
for i in range(1, n):
    ea = (x[i] - x[i-1]) * a
    eb = b

    if ea >= eb:
        c += eb
    else:
        c += ea

print(c)

Solution (Python):
if __name__=="__main__":
    [N, A, B] = map(int,input().split())
    xs = list(map(int,input().split()))
    d_xs = [xs[i] - xs[i-1] for i in range(1,len(xs))]
    s = 0
    for d in d_xs:
        if(d*A < B):
            s+=d*A
        else:
            s+=B
    print(s)

Solution (Python):
n, a, b = [int(x) for x in input().split()]
xs = [int(x) for x in input().split()]

ans = 0
for i in range(n-1):
    ans = ans + min((xs[i+1] - xs[i]) * a, b)

print(ans)

Solution (Python):
N, A, B = map(int, raw_input().split())
X = map(int, raw_input().split())

total = 0
for i in range(N-1):
	total += min(B, A*(X[i+1]-X[i]))
print total

Solution (Python):
N, A, B = map(int, input().split())
l = list(map(int, input().split()))
c = l[0]
f = 0
w = B/A 
for x in l:
    d = x - c
    if w < d: f += B
    else: f += d * A
    c = x
print(f)

Solution (Python):
n,a,b = map(int,input().split())
lis = list(map(int,input().split()))

c = []
for i in range(1,n):
    c.append(min(b,a*(lis[i]-lis[i-1])))
print(sum(c))

Solution (Python):
N,A,B=map(int,raw_input().split())
X=map(int,raw_input().split())
s=0
for i in range(1,N):
    s+=min(A*(X[i]-X[i-1]),B)
print s

Solution (Python):

N, A, B=map(int, input().split())
lis=list(map(int,input().split()))

out=0
for i in range(0,N-1):
    d=(lis[i+1]-lis[i])*A
    if d < B:
        out=out+d
    else:
        out=out+B
print(out)

Solution (Python):
n, a, b = map(int, input().split())
x = list(map(int, input().split()))

total = 0
for i in range(1, n):
    cost_a = (x[i] - x[i - 1]) * a
    total += cost_a if cost_a < b else b
print(total)

Solution (Python):
N, A, B = map(int,input().split());
X = list(map(int,input().split()));

dist =[X[i+1]-X[i] for i in range(N-1)];

fatigue = 0;
for i in dist:
    if i*A<B:
        fatigue += i*A;
    else:
        fatigue += B;

print(fatigue);

Solution (Python):
n, a, b = map(int, input().split())
x = list(map(int, input().split()))
ans = 0
for i, j in enumerate(x):
    if i + 1 < n:
        ans += min((x[i + 1] - j) * a, b)
print(ans)

Solution (Python):
N, A, B = map(int, raw_input().split())
X = map(int, raw_input().split())

D = [X[i+1] - X[i] for i in range(N-1)]
cost = [min(d * A, B) for d in D]
print sum(cost)

Solution (Python):
N, A, B = map(int, input().split())
X = list(map(int,input().split()))

diff = []
for i in range(1, len(X)):
    diff.append(X[i]-X[i-1])

fatigue = 0

for j in diff:
    if j * A > B:
        fatigue += B
    else:
        fatigue += j*A
        
print(fatigue)

Solution (Python):
N, A, B = map(int, input().split())
X = list(map(int, input().split()))

diff = [X[i + 1] - X[i] for i in range(len(X) - 1)]

fatigue = 0
for i in diff:
    if i * A < B:
        fatigue += i * A
    else:
        fatigue += B

print(fatigue)

Solution (Python):
def read(): return list(map(int, input().split()))

n, a, b = read()
city = read()
print(sum(list(min(a * (city[i] - city[i - 1]), b) for i in range(1, n))))

Solution (Python):
def read(): return list(map(int, input().split()))


n, a, b = read()
city = read()

ans = 0
for i in range(1, n):
    ans += min(a * (city[i] - city[i - 1]), b)

print(ans)

Solution (Python):
N, A, B = list(map(int, input().split()))
X = list(map(int, input().split()))
m = 0

for i in range(N-1):
    m += min(A*(X[i+1]-X[i]),B)

print(m)

Solution (Python):

N, A, B = [int(_) for _ in input().split()]
X = [int(_) for _ in input().split()]
diff = [X[i] - X[i-1] for i in range(1, N)]

ans = 0
for x in diff:
    ans += min(A*x, B)
print(ans)

Solution (Python):
N,A,B=map(int,raw_input().split())
x=map(int,raw_input().split())
count=0
for i in xrange(1,N):
	diff=x[i]-x[i-1]
	count+=(diff*A,B)[diff*A>B]
print count

Solution (Python):
def reads():
  return [int(x) for x in input().split()]

(N, A, B) = reads()
X = reads()

result = 0
for i in range(1, N):
  result += min(A*(X[i] - X[i-1]), B)
print(result)

Solution (Python):
n, a, b = map(int, input().split())
t = list(map(int, input().split()))
print(sum([min((t[i] - t[i-1])*a, b) for i in range(1, n)]))

Solution (Python):
n, a, b = map(int, input().split())

x = list(map(int, input().split()))

y = []
for i in range(1, len(x)):
	y.append(a*(x[i] - x[i-1]))

for i, l in enumerate(y):
	if l > b:
		y[i] = b

print(sum(y))

Solution (Python):
import functools
import sys
import math
input = lambda :sys.stdin.readline()
@functools.lru_cache(maxsize=10000)

def Main():
    N, A, B = map(int,input().split())
    Arr = list(map(int, input().split()))
    sm = 0
    for i in range(0, len(Arr) - 1):
        zemi = abs(Arr[i] - Arr[i + 1])
        
        sm += min((zemi*A), B)

    print(sm)

if __name__ == '__main__':
    Main()

Solution (Python):
n, a, b = map(int, input().split())
xs = list(map(int, input().split()))
dx = [0] * (n-1)
for i in range(n-1):
    dx[i] = xs[i+1] - xs[i]

res = 0
for i in range(n-1):
    if dx[i] * a < b:
        res += dx[i] * a
    else:
        res += b



print(res)

Solution (Python):
n = map(int, raw_input().split())
x = map(int, raw_input().split())
sum = n
i = 0
hiro = 0
while i!=n[0]-1:
    if (x[i+1]-x[i])*n[1]<n[2]:
        hiro = hiro + (x[i+1]-x[i])*n[1]
    else:
        hiro = hiro + n[2]
    i=i+1
print hiro

Solution (Python):
[N,A,B]=[int(i) for i in input().split()]
x=[int(i) for i in input().split()]
a=0
for i in range(N-1):
  if (x[i+1]-x[i])*A>B:
     a+=B
  else:
     a+=(x[i+1]-x[i])*A
print(a)

Solution (Python):

n, a, b = map(int, input().split())
townpos = list(map(int, input().split()))
step = townpos[0]
tsukare = 0
for x in townpos[1:]:
    tsukare += min((x-step)*a, b)
    step=x
print(tsukare)

Solution (Python):
import sys
import math

N, A, B = map(int, input().split())
X = [int(x) for x in input().split()]

ans = 0

for i in range(N - 1):
    ans += min(A * (X[i + 1] - X[i]), B)

print(ans)

Solution (Python):
n, a, b = map(int,input().split())
x = list(map(int,input().split()))

for i in range(n - 1, 0, -1):
    x[i] -= x[i - 1]

x[0] = 0

ans = 0
for i in range(n):
    if a * x[i] > b:
        ans += b
    else:
        ans += (a * x[i])

print(ans)

Solution (Python):
n, a, b = map(int, input().split())
x = [int(i) for i in input().split()]
cost = 0

for i in range(n - 1):
    diff = x[i + 1] - x[i]
    cost += min(diff * a, b)

print(cost)

Solution (Python):

if __name__=="__main__":
    N, A, B = list(map(int,input().strip().split()))
    X = list(map(int,input().strip().split()))

    result = 0
    for i in range(1,N):
        walk =  A*(X[i] - X[i-1]) 
        if walk < B:
            result += walk
        else:
            result += B
    print(result)

Solution (Python):
N,A,B=list(map(int,input().split()))
X=list(map(int,input().split()))

res=0
for i in range(N-1):
        res += min(A*(X[i+1]-X[i]), B)

print(res)

Solution (Python):
data = list(map(int, input().split()))
N, A, B = data
dist = list(map(int, input().split()))
cost = 0
for i in range(N-1):
    cost += min((dist[i+1] - dist[i])*A, B)
print(cost)

Solution (Python):
n, a, b = map(int, input().split())
xi = list(map(int, input().split()))
ans = 0
 
for i in range(1, n):
	ans += (min(((xi[i] - xi[i-1])*a), b))
 
print(ans)

Solution (Python):
n,a,b = map(int,input().split())
x = list(map(int,input().split()))
count = 0
for i in range(n-1):
    r = x[i+1] - x[i]
    if a*r <= b:
        count += a*r
    else:
        count += b
print(count)

Solution (Python):
N, A, B = map(int, input().split())
X = list(map(int, input().split()))

OPT = [0 for i in range(N)]
for i in range(1, N):
	OPT[i] = OPT[i-1]+min((X[i]-X[i-1])*A, B)
print(OPT[N-1])

Solution (Python):
n,a,b = map(int,input().split())
ar = [int(x) for x in input().split()]
f = 0
for i in range(n-1):
    t = ar[i+1]-ar[i]
    if t*a > b:
        f += b
    else:
        f += t*a

print(f)

Solution (Python):
n, a, b = map(int, raw_input().split())
l = map(int, raw_input().split())
init = l[0] - 1
for i in xrange(0,len(l)):
    l[i] = l[i] - init
ans = 0
for i in xrange(1,n):
    ans = ans + min((l[i] - l[i-1]) * a, b)
print ans

Solution (Python):



def read():
    N, A, B = map(int, raw_input().split())
    posList = map(int, raw_input().split())
    return A, B, posList


def work((A, B, posList)):
    ans = 0
    for i in range(len(posList) - 1):
        ans += min(A * (posList[i + 1] - posList[i]), B)
    print ans


if __name__ == "__main__":
    work(read())

Solution (Python):
N,A,B = [int(i) for i in raw_input().split(' ')]
X = [int(i) for i in raw_input().split(' ')]
x_old = X[0]
h = 0
for x in X:
  d = x - x_old
  if d*A>B:
    h += B
  else:
    h += d*A
  x_old = x
print h