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.



Sample input:
4 2 5
1 2 5 7


Sample output:
11

Submission status: Accepted

Solution code:
import sys

# sys.stdin = open('d1.in')


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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

# N, A, B, Xiの入力
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
#coding: UTF-8
N, A, B=map(int, input().split())
lis=list(map(int,input().split()))
#print(lis)
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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);

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:

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)

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)]))

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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])
        # print(zemi)
        sm += min((zemi*A), B)

    print(sm)

if __name__ == '__main__':
    Main()

Submission status: Accepted

Solution code:
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(xs)
#print(dx)
print(res)

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
[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)

Submission status: Accepted

Solution code:
#listつけわすれ
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:

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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
#!/usr/bin/env 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())

Submission status: Accepted

Solution code:
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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

print(ans)

Submission status: Runtime Error

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

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

print(ans)

Submission status: Runtime Error

Solution code:
n,a,b = map(int, input().split())
x = [int(x) for x in input().split(' ')]

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

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
s=list(map(int,input().split())
t=0
for i in range(n-1):
	t+=min(b,a*(s[i+1]-s[i]))

print(t)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
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] - b)

print(ans)

Submission status: Runtime Error

Solution code:
from collections import deque

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

INF = float("inf")

dist = deque(X)

next_x = +1
i = 0
ans = 0
while len(dist) != 1:

    if A*abs(dist[i+next_x] - dist[i]) <= B:
        ans += A*abs(dist[i+next_x] - dist[i])
        if next_x == 1:
            dist.popleft()
            i = 0
        else:
            dist.pop()
            i = len(dist)
    else:
        ans += B
        if next_x == 1:
            dist.popleft()
            i = len(dist)-1
        else:
            dist.pop()
            i = 0
        
        next_x = -next_x
        
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
coding: UTF-8
N, A, B=map(int, input().split())
lis=list(map(int,input().split()))
#print(lis)
out=0
for i in range(0,N-1):
    d=lis[i+1]-lis[i]
    if d*A < B:
        out=out+d*A
    else:
        out=out+B
print(out)

Submission status: Runtime Error

Solution code:
N, A, B = map(int,input().split());
X[N] = map(int,input().split);

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

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

print(fatigue);

Submission status: Runtime Error

Solution code:
import numpy as np


N,A,B = map(int,raw_input().split())

city = raw_input()

ci = city.split(" ")

path = []

for i in range(len(ci)-1):
    z = int(ci[i+1])-int(ci[i])
    path.append(z)

costa = []

def binary_encode(i, num_digits):
    return np.array([i >> d & 1 for d in range(num_digits)])

for i in range(2**len(path)):
    pc = binary_encode(i,len(path))
    cost =0
    for z in range(len(pc)):
        if pc[z] == 0:
            cost = cost + A *path[z]
        else:
            cost = cost + B

    costa.append(cost)

print min(costa)

Submission status: Runtime Error

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

city = raw_input()

ci = city.split(" ")

path = []

for i in range(len(ci)-1):
    z = int(ci[i+1])-int(ci[i])
    path.append(z)

costa = []

def binary_encode(i, num_digits):
    return np.array([i >> d & 1 for d in range(num_digits)])

for i in range(2**len(path)):
    pc = binary_encode(i,len(path))
    cost =0
    for z in range(len(pc)):
        if pc[z] == 0:
            cost = cost + A *path[z]
        else:
            cost = cost + B

    costa.append(cost)

print min(costa)

Submission status: Runtime Error

Solution code:
import numpy as np


N,A,B = map(int,raw_input().split())

city = raw_input()

ci = city.split(" ")

path = []

for i in range(len(ci)-1):
    z = int(ci[i+1])-int(ci[i])
    path.append(z)

costa = []

def binary_encode(i, num_digits):
    return np.array([i >> d & 1 for d in range(num_digits)])

for i in range(2**len(path)):
    pc = binary_encode(i,len(path))
    cost =0
    for z in range(len(pc)):
        if pc[z] == 0:
            cost = cost + A *path[z]
        else:
            cost = cost + B

    costa.append(cost)

print min(costa)
~                                                                                                         
~

Submission status: Runtime Error

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