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:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()

    return

#B
def B():
    n = I()

    return

#C
def C():
    n = I()

    return

#D
def D():
    def root(x):
        if x == par[x]:
            return x
        par[x] = root(par[x])
        return par[x]

    def unite(x,y):
        x = root(x)
        y = root(y)
        if rank[x] < rank[y]:
            par[x] = y
        else:
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1

    n,a,b = LI()
    par = [i for i in range(n)]
    rank = [0]*n
    x = LI()
    for i in range(n-1):
        if a*(x[i+1]-x[i]) < b:
            unite(i,i+1)
    ans = 0
    f = [1]*n
    f[0] = 0
    for i in range(1,n):
        if f[root(i)]:
            ans += b
            f[root(i)] = 0
        else:
            ans += a*(x[i]-x[i-1])
    print(ans)
    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    D()

Submission status: Accepted

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

nums=list(map(int,input().split()))
tmp=nums[0]
ans=0
for num in nums[1:]:
  if (num-tmp)*a<=b: 
    ans+=(num-tmp)*a
  else:
    ans+=b
  tmp=num

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
D - Walk and Teleport
https://atcoder.jp/contests/arc067/tasks/arc067_b

"""
import sys


def solve(N, A, B, X):
    gaps = [z-y  for y, z in zip(X, X[1:])]
    ans = 0
    for g in gaps:
        if g*A <= B:
            ans += g*A
        else:
            ans += B
    return ans


def main(args):
    N, A, B = map(int, input().split())
    X = [int(x) for x in input().split()]
    ans = solve(N, A, B, X)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
#D問題
N,A,B = map(int,input().split())
X = list(map(int,input().split()))
ans = 0
now = 0
for i in range(N):
    if i == 0:
        now = X[0]
    else:
        ans += min((X[i]-now)*A,B)
        now = X[i]
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
*x,=map(int,input().split())
print(sum(min(abs(a*(x[i-1]-x[i])),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()))

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
inf = float('inf')


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

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
n,a,b = map(int,input().split())
kyori = []
telepo = math.ceil(b / a)
counter = 0
ans = 0
x = list(map(int,input().split()))
for i in range(1,n):
    tmp = x[i] - x[i-1]
    if tmp >= telepo:
        counter +=1
    else:
        kyori.append(tmp)
for i in kyori:
    ans +=a*i
ans = ans + counter * b
print(ans)

Submission status: Accepted

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

# 町1, 町2, ..., 町Nの順に訪問する
ans = sum(
    min(A * (r - l), B)
    for l, r in zip(X, X[1:])
)

# 出力
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

d_max = B // A + 1

cost = 0
x_1 = X_list.pop()
while(X_list):
    x_2 = X_list.pop()
    d = x_1 - x_2
    if d < d_max:
        cost += A * d
    else:
        cost += B
    x_1 = x_2

print(cost)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
ans = 0
v = list(map(int, input().split()))
for i in range(n):
  if i:
    ans += min(a * (v[i] - last), b);
  last = v[i]
print(ans)

Submission status: Accepted

Solution code:
N, A, B = [int(_) for _ in input().split()]
X = [int(_) for _ 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()))
ans = 0

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

Submission status: Accepted

Solution code:
from itertools import accumulate
from math import*
from collections import deque
from collections import defaultdict
from itertools import permutations
from heapq import*
from collections import Counter
from itertools import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**18
from functools import reduce

n,a,b = map(int,input().split())
x = list(map(int,input().split()))
edge = []
class UnionFind():
    def __init__(self, N):
        self.rank = [0] * N
        self.par = [i for i in range(N)]
        self.counter = [1] * N

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            z = self.counter[x] + self.counter[y]
            self.counter[x], self.counter[y] = z, z
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def size(self, x):
        x = self.find(x)
        return self.counter[x]

    def same(self, x, y):
        return self.find(x) == self.find(y)
for i in range(1,n):
    c = (x[i]-x[i-1])*a
    edge.append((c,i-1,i))
#クラスカル法
uf = UnionFind(n)
edge.sort()
ans = 0
edge_cnt = 0
i = 0
while edge_cnt < n-1:
    cost,i1,i2 = edge[i]
    if not uf.same(i1,i2):
        ans += min(b,cost)
        uf.unite(i1,i2)
        edge_cnt += 1
    i += 1
print(ans)

Submission status: Accepted

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

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

res = 0

now = x[0]

for nxt in x[1:]:
    dis = nxt - now
    if dis*a>b:
        res+=b
    else:
        res+=dis*a
    now = nxt
print(res)

Submission status: Accepted

Solution code:
# 歩く部分は連結。左から右としてよい。
# 結局ワープも左から右としてよい。

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

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

Submission status: Accepted

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

print(l)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import Counter
sys.setrecursionlimit(10**7)
mo=10**9+7
n=10**5

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

Submission status: Accepted

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

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

solve()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
from functools import partial, reduce
from operator import mul
prod = partial(reduce, mul)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N, A, B = LI()
    X = LI()
    ans = 0
    for x, y in zip(X, X[1:]):
        if (y - x) * A < B:
            ans += (y - x) * A
        else:
            ans += B
    return ans

print(main())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

prevx = xlist[0]
c = 0
for x in xlist[1:]:
  if (x - prevx) * a > b:
    c += b
  else:
    c += (x - prevx) * a
  prevx = x
print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
while True:
    try:
        n,a,b=map(int,input().split())
    except:
        break
    thelist=list(map(int,input().split()))
    t=b//a
    sum=0
    for i in range(1,n):
        tt=thelist[i]-thelist[i-1]
        if tt>t:
            sum+=b
        else:
            sum+=a*tt
    print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

ans = 0
L = list(map(int, input().split()))

diff = [0]*N
for i in range(N):
    diff[i] = L[i]-L[i-1]

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

Submission status: Accepted

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

print(num)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

def main():
    n, a, b = map(int, input().split())
    xn = list(map(int, input().split()))

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

main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, A, B = map(int,input().split())
X = [int(i) for i in input().split()]
X.insert(0,0)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

"""
N=int(input())

print(800*N-int(N/15)*200)
"""
"""
N=int(input())
S=input()

max_n=0
temp=0
for strng in S:
	if strng=="I":
		temp+=1
		if max_n<temp:
			max_n=temp
	else:
		temp-=1
print(max_n)
"""
"""
N=int(input())

Q=1000000007
p=1
for i in range(1,N+1):
	p*=i
	p=p%Q
print(p%Q)
"""

"""
n=int(input())
S=[input() for i in range(n)]
alphabet_dict={chr(97+i):100 for i in range(26)}
for s in S:
	temp={chr(97+i):0 for i in range(26)}
	for i in s:
		temp[i]+=1

	for key in alphabet_dict.keys():
		if alphabet_dict[key]>temp[key]:
			alphabet_dict[key]=temp[key]
result=""
for item in alphabet_dict.items():
	for i in range(item[1]):
		result+=item[0]
if result=="":
	print("\n")
else:
	print(result)
"""
"""
(N,M) = [int(i)for i in input().split()]

if N>int(M/2):
	print(int(M/2))
else:
	hoge=int(M/2)-N
	print(N+int(hoge/2))
"""
(N,A,B) = [int(i)for i in input().split()]
X=[int(i) for i in input().split()]

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n,a,b = map(int, input().split())
x = [int(i) for i in input().split()]

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

Submission status: Accepted

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

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

print(s)

Submission status: Accepted

Solution code:
def inpl(): return [int(i) for i in input().split()]

N,A,B = inpl()
Xi = inpl()
dist =[]
ans = 0
for i in range(N-1):
    dist.append(Xi[i+1]-Xi[i])
for i in range(N-1):
    if dist[i]*A <B:
        ans += dist[i]*A
    else:
        ans += B

print(ans)

Submission status: Accepted

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

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):
    ans+=min([(X[i+1]-X[i])*A,B])

print ans

Submission status: Accepted

Solution code:
S1=input()
S1=S1.split()
S2=input()
S2=S2.split()
move=0
N=int(S1[0])
A=int(S1[1])
B=int(S1[2])
for i in range(N-1):
    div=int(S2[i+1])-int(S2[i])
    if (div)*A>=B:
        move+=B
    else:
        move+=A*(div)
print(move)

Submission status: Accepted

Solution code:
S1=input()
S1=S1.split()
S2=input()
S2=S2.split()
move=0
N=int(S1[0])
A=int(S1[1])
B=int(S1[2])
for i in range(N-1):
    if (int(S2[i+1])-int(S2[i]))*A>=B:
        move+=B
    else:
        move+=A*(int(S2[i+1])-int(S2[i]))
print(move)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,a,b,*x=map(int,open(0).read().split());print(sum(min((x[i]-x[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()))
ans = 0
for i in range(n - 1):
    dx = (x[i + 1] - x[i]) * a
    if dx < b:
        ans += dx
    else:
        ans += b
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ai = lambda: list(map(int, input().split()))

n,a,b = ai()
x = ai()

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

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

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

print ans

Submission status: Accepted

Solution code:
import sys
from collections import deque
import copy

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, A, B] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
    score = 0
    input_raw = read_func().strip().split()
    for i in range(N - 1):
        XL = int(input_raw[i])
        XR = int(input_raw[i + 1])
        if A*(XR - XL) < B:
            score += A*(XR - XL)
        else:
            score += B
    print score


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)


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


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


print(hirou)

Submission status: Accepted

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

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

Submission status: Accepted

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

su = 0
c = [0]
for  i in range(len(b)-2):
	c.append(0)

for i in range(a[0] - 1):
	c[i] = b[i+1] - b[i]

for i in range(len(c)):
	if a[2] <= c[i]*a[1]:
		su += a[2]
	else:
		su += c[i]*a[1]

print(su)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stderr
from functools import reduce
from operator import add
def f(): return [int(i) for i in input().split()]
def debug(*x): stderr.write(reduce(add,repr(x)).strip("()\',")+'\n')

n,a,b = f()
x = sorted(f())
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections


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

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
from math import *
import numpy as np

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

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

print(t)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
n, a, b = map(int, raw_input().split(' '))
v = map(int, raw_input().split(' '))

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

print res

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
[n,a,b]=[int(i) for i in input().split()]
x=[int(i) for i in input().split()]
y=[]
for i in range(n-1):
 z=(x[i+1]-x[i])*a
 if z<b:
   y.append(z)
 else:
   y.append(b)
print(sum(y))

Submission status: Accepted

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

diff_X = [i-j for i,j in zip(X[1:], X[:-1])]

res = 0
for i in range(len(diff_X)):
    if A*diff_X[i] < B:
        res += A*diff_X[i]
    else:
        res += B

print(res)

Submission status: Accepted

Solution code:
import numpy as np

n, a, b = map(int, input().split())
towns = list(map(int, input().split()))
print(sum(np.minimum(np.diff(towns) * a, b)))

Submission status: Accepted

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

val = 0

for X1, X2 in zip(X_list[:-1], X_list[1:]):
    A_val = A*(X2-X1) 
    if A_val > B:
        val += B
    else:
        val += A_val
print (val)

Submission status: Accepted

Solution code:
#ARC067D

n,a,b=map(int,raw_input().split())
x=map(int,raw_input().split())
res=0
for i in xrange(1,n):
 res+=min((x[i]-x[i-1])*a,b)
print res

Submission status: Accepted

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

xi = []
xi.append(inputs[0])
hirou = 0

for i in range(1, N):
    xi.append(inputs[i])
    diff = xi[i] - xi[i-1]
    if diff * A > B:
        hirou += B
    else:
        hirou += A * diff

print(hirou)

Submission status: Accepted

Solution code:

def main():
    [n, a, b] = list(map(int,input().split()))
    m = list(map(int,input().split()))
    cost = 0
    for i in range(1, n):
        cost += min([a*(m[i]-m[i-1]), b])
    print(cost)


if __name__ == "__main__":
    import sys
    import os
    if len(sys.argv) > 1:
        if sys.argv[1] == "-d":
            filename = "input1.txt"
            fd = os.open(filename, os.O_RDONLY)
            os.dup2(fd, sys.stdin.fileno())
            main()
    else:
        main()

Submission status: Accepted

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

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

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n, a, b = map(int, raw_input().strip().split(" "))

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

Submission status: Accepted

Solution code:
import sys

##sys.stdin = open("in.txt","r")
cin = sys.stdin
##sys.stdout = open("out.txt","w")
cout = sys.stdout

def solve():
    N, A, B = map(int,cin.readline().split())
    X = list(map(int, cin.readline().split()))
    cnt = 0
    for i in range(1,N):
        cnt += min((X[i]-X[i-1])*A , B)
    print(cnt)

if __name__=="__main__":
    solve()

Submission status: Accepted

Solution code:
import numpy as n;i=lambda:n.fromstring(input(),dtype=int,sep=' ');N,A,B=i();print(int(sum(n.diff(i()*A).clip(0,B))))

Submission status: Accepted

Solution code:
import numpy as n;i=lambda:n.fromstring(input(),sep=' ');N,A,B=i();X=n.diff(i())*A;X[X>B]=B;print(int(sum(X)))

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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

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

    print(cost)

__main__()

Submission status: Accepted

Solution code:
insp = lambda: list(map(int, input().split()))

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

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

c=0
for i in range(len(l)-1):
	if (l[i+1]-l[i])*A<B:
		c+=(l[i+1]-l[i])*A
	else:
		c+=B

print(c)