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: Wrong Answer

Solution code:
a,b,c=map(int,input().split())
d=list(map(int,input().split()))
e=0

for i in range(a-1):
    f=(d[i+1]-d[i])*b

    if(f>c):
        e+=f
    else:
        e+=c

print(e)

Submission status: Wrong Answer

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

if b <= a:
  print(n*b)
  exit()

diff = [0]*(n-1)
for i in range(n-1):
  diff[i] = x[i+1] - x[i]

m = b/a
ans = 0
for i in diff:
  if i < m: ans += a*i
  else: ans += b
print(ans)

Submission status: Wrong Answer

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

if b <= a:
  print(n*b)
  exit()

diff = [0]*(n-1)
for i in range(n-1):
  diff[i] = x[i+1] - x[i]

m = b/a
ans = 0
for i in diff:
  ans += min(a*i, b)
print(ans)

Submission status: Wrong Answer

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

if b <= a:
  print(n*b)
  exit()

diff = [0]*(n-1)
for i in range(n-1):
  diff[i] = x[i+1] - x[i]

m = b/a
ans = 0
for i in diff:
  if i <= m: ans += a*i
  else: ans += b
print(ans)

Submission status: Wrong Answer

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

if b <= a:
  print(n*b)
  exit()

diff = [0]*(n-1)
for i in range(n-1):
  diff[i] = x[i+1] - x[i]

m = b/a
ans = 0
for i in diff:
  if i < m: ans += a*i
  else: ans += b
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(diff)

res = 0
for d in diff:
	res += min(d * a, b)

print(res)

Submission status: Wrong Answer

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

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

res = 0
for d in diff:
	res += min(d, b)

print(res)

Submission status: Wrong Answer

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

ans=0
pre=X[0]

for xi in X[1:]:
    if (xi-pre)*A-B>0:
        ans+=B
    else:
        ans+=(xi-pre)
    pre=xi

print(ans)

Submission status: Wrong Answer

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

ans = 0
for i in range(n-1):
    ans += min(c[i+1] - c[i], b)
print(ans)

Submission status: Wrong Answer

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

fatigue = 0
for i in range(n-1):
  d = towns[i+1] -towns[i]
  fatigue = max(d*a,b)
print(fatigue)

Submission status: Wrong Answer

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

hp = 0
good = min(a, b)
bad = max(a, b)

for i in range(n):
  if i+1 == n:
    break
  if bad >= abs(x[i+1] - x[i])*good:
    hp += abs(x[i+1] - x[i]) * good
  else:
    hp += bad
    
print(hp)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

for i in range(N-1):
    M=X[i+1]-X[i]
    if M>=B:
        count+=M
    else:
        count+=B
print(count)

Submission status: Wrong Answer

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

# Input
s = [input() for i in range(2)]

N = int(s[0].split()[0])
A = int(s[0].split()[1])
B = int(s[0].split()[2])
X = s[1].split()


F = 0

# 疲労度の少ない方法を逐次選択する
for i in range(0, N-1):
    if A*(int(X[i+1]) - int(X[i])) >= B:
        F = F + B
    else:
        F = F + A*(int(X[i+1]) - int(X[i]))
    print(F)

# Output
print(F)

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
n, a, b = [ int(v) for v in input().split() ]
town_list = [ int(v) for v in input().split() ]
fatigue_list = [ 0 for i in range(n) ]

for i in range(n-1):
	d = town_list[i+1] - town_list[i]
	fatigue_list[i+1] = fatigue_list[i] + min(a*d,b)
print(fatigue_list)

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
x=list(map(int,input().split()))
ans=0
if a>=b:
  print(b*n)
else:
  d=b//a
  
  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: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
x=list(map(int,input().split()))
ans=0
if a>=b:
  print(b*n)
else:
  d=b//a
  
  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: Wrong Answer

Solution code:
N,A,B = [ int(it) for it in input().split() ]
li = [ int(it) for it in input().split() ]
s = 0
for i in range(len(li)-1):
  d = li[i+1] - li[i]
  if (d<B//A):
    s += d*A
  else:
    s += B
print (s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
X = list(map(int, input().split()))
x1 = X[0]
cost = [min(A * abs(x - x1), B) for x in X]

print(sum(cost))

Submission status: Wrong Answer

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))]
    print(d_xs)
    s = 0
    for d in d_xs:
        if(d*A < B):
            s+=d*A
        else:
            s+=B
    print(s)

Submission status: Wrong Answer

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-A):
        out=out+d*A
    else:
        out=out+B
print(out)

Submission status: Wrong Answer

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 < (B-A):
        out=out+d
    else:
        out=out+B
print(out)

Submission status: Wrong Answer

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)]
print(diff)

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

print(fatigue)

Submission status: Wrong Answer

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

    distance = 0
    MST = [0]
    VT = [False] + [True]*(N-1)

    now = 0
    for n in range(N-1):
        mincos = float('inf')
        for i,x in enumerate(X):
            if VT[i] == True:
                tmp = min(math.fabs(x-X[now])*A, B)
                if tmp < mincos:
                    mincos = tmp
                    now = i
        MST.append(now)
        VT[now] = False
        distance += mincos

    print(int(distance))

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

I = []
for i in range(N-1):
    I.append(X[i+1]-X[i])

M = X[N-1]-X[0]
I_srt = sorted(I)
I_srt.reverse()


ans = min([(M-sum(I_srt[:i]))*A + B*i for i in range(N)])

print(ans)

Submission status: Time Limit Exceeded

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

    distance = 0
    MST = [0]
    VT = [False] + [True]*(N-1)

    now = 0
    for n in range(N-1):
        mincos = float('inf')
        for i,x in enumerate(X):
            for p in MST:
                if VT[i] == True:
                    tmp = min(math.fabs(x-X[p])*A, B)
                    if tmp < mincos:
                        mincos = tmp
                        now = i
        MST.append(now)
        VT[now] = False
        distance += mincos

    print(int(distance))
        


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n, a, b= map(int, input().split())
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: Accepted

Solution code:
N,A,B = map(int,input().split())
lsX = list(map(int,input().split()))
ans = 0
for i in range(1,N):
    ans += min((lsX[i] - lsX[i-1])*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(n - 1):
    res += min(b, (x[i + 1] - x[i]) * a)

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):
    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 = list(map(int,input().split()))
X = list(map(int,input().split()))

ans = 0
for s,e in zip(X[:-1],X[1:]):
    ans += min(B,A*(e-s))
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):
    ans += min(a * (x[i] - x[i-1]), 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:
def main():
	N, A, B = [int(n) for n in input().split(" ")]
	X = [int(x) for x in input().split(" ")]
	D = []
	for i in range(1, len(X)):
		D.append(X[i] - X[i - 1])
	print(sum([min(A * d, B) for d in D]))

main()

Submission status: Accepted

Solution code:
def main():
    n, a, b = list(map(int, input().split()))
    x = list(map(int, input().split()))
    quantty = 0
    # ans = []
    for i in range(len(x)):
        if i == len(x) - 1:
            break
        quantty += min(a*(x[i+1] - x[i]), b)
        # ans.append(quantty)
    print(quantty)



if __name__ == '__main__':
    main()

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()))
print(sum(min(A*(X[i+1]-X[i]),B) for i in range(N-1)))

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
from operator import itemgetter

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, A, B = na()
X = na()
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()))

sa_cost = [0] * (N - 1)
for i in range(N - 1):
    sa_cost[i] = (X[i + 1] - X[i]) * A


ans = 0
for i in range(len(sa_cost)):
    if sa_cost[i] <= B:
        ans += sa_cost[i]
    else:
        ans += B

print(ans)

Submission status: Accepted

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

print(Sum)

Submission status: Accepted

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

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

	else:
		cost+=B 

print(cost)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
num_towns, cost_walk, cost_warp = map(int, input().split())
positions = list(map(int, input().split()))

total_cost = 0
for p1, p2 in zip(positions[:-1], positions[1:]):
    c_walk = (p2 - p1) * cost_walk
    if c_walk < cost_warp:
        total_cost += c_walk
    else:
        total_cost += cost_warp

print(total_cost)

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
X=list(map(int,input().split()))
ans = 0
x = X[0]
for i in range(N):
    ans += min((X[i]-x)*A, B)
    x = X[i]
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(A*(X[i+1]-X[i]), B)
print(ans)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
X = [int(x) for x in input().split()]
ans = 0
for x,y in zip(X[:N-1],X[1:]):
    if (y-x) * A < B:
        ans += (y-x) * A
    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 i in range(n-1):
    ans+=min(a*(x[i+1]-x[i]),b)
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def main():
  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)
  
  
  
  
  
if __name__ == "__main__":
  main()

Submission status: Accepted

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

diff = []
for i in range(n-1):
    diff.append(a*(L[i+1]-L[i]))
#print(diff)
cnt = 0
for i in range(n-1):
    if diff[i] > b:
        cnt +=1
diff.sort()

print(sum(diff[:n-1-cnt]) + b*cnt)

Submission status: Accepted

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

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

print(sum(d2))

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):
    xs = x[i + 1] - x[i]
    if xs * a < b:
        ans += xs * a
    else:
        ans += b

print(ans)

Submission status: Accepted

Solution code:
import sys
from heapq import heappush, heappop
def input(): return sys.stdin.readline().strip()


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




if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
town = list(map(int, input().split()))
dist = []
for i in range(n-1):
  dist.append((town[i+1]-town[i])*a)

ans = 0
for i in range(n-1):
  ans += min(dist[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):
    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()))

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

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

print(ans)

Submission status: Accepted

Solution code:
#7 1 100
#40 43 45 105 108 115 124
n,a,b = map(int, raw_input().split())
xis = map(int ,raw_input().split())
cost = 0
for u,v in zip(xis,xis[1:]):
	cost += min((v-u)*a, b)
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):
    aa = (x[i+1] - x[i]) * a
    if aa < b:
        ans += aa
    else:
        ans += b

print(ans)

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):
     dist = x[i+1] - x[i]
     cost += min(dist*a, b)
print(cost)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
X = list(map(int, input().split()))
ans = 0
town = X[0]
for i in range(1,N):
    ans += min(B, (X[i]-town)*A)
    town = X[i]
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):
    num=x[i+1]-x[i]
    ans+=min(b,a*num)
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):
    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=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 = [int(s) for s in input().split()]
x_list = [int(s) for s in input().split()]
ans = 0
for i in range(n - 1):
    ans += min(a * (x_list[i + 1] - x_list[i]), b)
print(ans)

Submission status: Accepted

Solution code:
k=0
def s(a):
  return min(a*A,B)
N,A,B=map(int,input().split())
L=list(map(int,input().split()))
for i in range(N-1):
  k+=s(L[i+1]-L[i])
print(k)

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):
  ans += min(b, a*(x[i]-x[i-1]))
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(a*(x[i+1]-x[i]), b)
print(ans)

Submission status: Accepted

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

cost = 0
for J in range(len(array)-1):
        walk_cost = (array[J+1] - array[J])*A
        if walk_cost < B:
            cost += walk_cost
        else:
            cost += B
print(cost)

Submission status: Accepted

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

if not ( 2 <= N <= 10**5 and 1 <= A <= 10**9 and 1 <= B <= 10**9 ): sys.exit()
for I in range(len(array)):
    if not ( 1 <= array[I] <= 10**9 ): sys.exit()
    if array[I] != array[-1]:
       if not ( array[I] < array[I+1] ): sys.exit()

cost = 0
for J in range(len(array)):
    if array[J] != array[-1]:
        walk_cost = (array[J+1] - array[J])*A
        if walk_cost < B:
            cost += walk_cost
        else:
            cost += B
print(cost)

Submission status: Accepted

Solution code:
n, a, b, *x = map(int, open(0).read().split())
print(sum(min((j - i) * a, b) for i, j in zip(x, x[1:])))

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

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
xs = list(map(int, input().split()))
res = 0
for i in range(n-1):
    walk = (xs[i+1]-xs[i])*a
    if walk <= b:
        res += walk
    else:
        res += 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):
    d = X[i] - X[i - 1]
    if d * A > B:
        ans += B
    else:
        ans += d * A
print(ans)

Submission status: Accepted

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

res = 0
pos = x[0]
for town in x[1:]:
    res += min((town - pos) * a, b)
    pos = town

print(res)

Submission status: Accepted

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


ans = 0
for x1,x2 in zip(xl[:-1],xl[1:]):
    diff = x2-x1
    walk_cost = diff*a
    ans += min(walk_cost, b)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, A, B, *X = map(int, read().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)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline

n,a,b=map(int,input().split())
x=list(map(int,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:
import sys

def main():
    N,A,B=map(int,input().split())
    towns=list(map(int,sys.stdin.readline().strip().split()))
    f=lambda x:min(A*x,B)
    fl=0
    for x in range(N-1):
        fl+=f(towns[x+1]-towns[x])
    print(fl)

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N,A,B = MI()
X = LI()

# 左から考えていく

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

    print(res)
if __name__ == '__main__':
    main()

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:
N,A,B = map(int,input().split())
ARR = list(map(int,input().split()))
def calculate(n,a,b,arr):

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

    print(result)

calculate(N,A,B,ARR)

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):
    ans+=min(a*(x[i+1]-x[i]),b)

print(ans)

Submission status: Accepted

Solution code:


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


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, A, B = read_ints()
    X = read_ints()
    answer = 0
    for i in range(1, N):
        answer += min(A*(X[i]-X[i-1]), B)
    return answer


if __name__ == '__main__':
    print(solve())

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:
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]
    if d*A<=B:
        ans+=d*A
    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 i in range(n - 1):
    d = X[i + 1] - X[i]
    ans += min(a * d, b)

print(ans)

Submission status: Accepted

Solution code:
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
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)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	n, a, b = LI()
	pos, *x_list = LI()
	cost = 0
	for x in x_list:
		if abs(x-pos)*a < b:
			cost += abs(x-pos) * a
		else:
			cost += b
		pos = x
	print(cost)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N,A,B,*X = map(int, open(0).read().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()))
xp = x[0]
ans = 0

for xi in x[1:]:
  ans += min((xi-xp)*a, b)
  xp = xi
  
print(ans)

Submission status: Accepted

Solution code:
import sys;input = lambda : sys.stdin.readline()
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]
    ans += min(b, d * a)
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):
    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 = map(int,input().split())
X = list(map(int,input().rstrip().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 = tuple(map(int, input().split()))
ans = 0
for x0, x1 in zip(X[:n-1], X[1:]):
    ans += min(b, a*(x1-x0))
print(ans)

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,a,b,*l=map(int,open(0).read().split())
t,p=0,l[0]
for i in l:
  t+=min(a*(i-p),b)
  p=i
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(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:
N, A, B = map(int,input().split())
XN = list(map(int,input().split()))

ans = 0
for n in range(N-1):
  xl = XN[n]
  xr = XN[n+1]
  dist = xr - xl
  ans += min(dist*A, B)
print(ans)

Submission status: Accepted

Solution code:
t = list(map(int, input().split()))
k = list(map(int, input().split()))

h = 0
for i in range(0,len(k)-1):
    if (k[i+1]-k[i])*t[1] > t[2]:
        h += t[2]
    else:
        h += (k[i+1]-k[i])*t[1]
print(h)