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,math,collections,itertools
input = sys.stdin.readline

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

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

print(ans)

Submission status: Accepted

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


def solve(N: int, A: int, B: int, X: "List[int]"):
    return sum(min(A*(a1-a0), B) for a0, a1 in zip(X, X[1:]))

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    X = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, A, B, X))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()

Submission status: Accepted

Solution code:
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    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)

    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    N, A, B = map(int, input().split())
    X = list(map(int, input().split()))
    walk = []
    for i in range(N-1):
        diff = X[i+1] - X[i]
        if diff*A < B:
            walk.append(diff)
    print(A*sum(walk) + B*(N-1 - len(walk)))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b,*x=map(int,open(0).read().split())
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:
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
now = xlst[0]
for x in xlst[1:]:
    ans += min(a * (x - now), b)
    now = x
print(ans)

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, A, B = LI()
    X = LI()

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

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

xx=[]
ans=0
for i in range(n-1):
    xx.append(a*(x[i+1]-x[i]))


for i in range(len(xx)):
    if xx[i]<b:
        ans+=xx[i]
    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):
    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().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:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, a, b = MAP()
x = LIST()
ans = 0

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

print(ans)

Submission status: Accepted

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

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:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,a,b = readInts()
X = readInts()
cnt = 0
for i in range(n-1):
    cnt += min((X[i+1]-X[i]) * a, b)
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

# 1移動でA　テレポートでB
now = X[0]
ans = 0
for x in X[1:]:
    if abs(now-x)*a < b: ans += abs(now-x)*a
    else: ans += b
    now = x
print(ans)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import numpy
N, A, B = map(int, input().split())
X = numpy.array(list(map(int, input().split())))
D = numpy.diff(X) * A
D[D > B] = B
print(sum(D))

Submission status: Accepted

Solution code:
import sys
import numpy as np
input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    n, a, b = map(int, input().rstrip().split())
    x = list(map(int, input().rstrip().split()))
    ans = 0
    for diff in np.diff(x):
        if diff * a < b:
            ans += diff * a
        else:
            ans += b
    print(ans)


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

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

print(cost)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# input
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
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)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

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

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,a,b,*x = map(int,read().split())


d = [i-j for i,j in zip(x[1:],x)]

#print(d)

ans = 0
for i in d:
    ans += min(i*a,b)

print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

    ans = 0

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

Submission status: Accepted

Solution code:
(n, a, b), xx = [list(map(int, s.split())) for s in open(0)]

suc = xx.pop()

dx = []

while len(xx):
    prec = xx.pop()
    dx.append(suc-prec)
    suc = prec

dx = [min(d*a, b) for d in dx]

print(sum(dx))

Submission status: Accepted

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

ds = [0] * (n+10)
for i in range(n-1):
    cost1 = a*(Xs[i+1] - Xs[i])
    cost2 = b
    ds[i+1] = ds[i] + min(cost1, cost2)
print(ds[n-1])

Submission status: Accepted

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

fatigue=0
for i in range(1,n):
  fatigue+=min((x[i]-x[i-1])*a,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 in range(1,n):
  dist=x[i]-x[i-1]
  ans+=min(dist*a, b)

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

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

Submission status: Accepted

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

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

print(fatigue)

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

Submission status: Accepted

Solution code:
#import sys
#import numpy as np
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n,a,b=map(int,input().split())
x=list(map(int,input().split()))
d=[0]*n
for i in range(1,n):
  d[i]=x[i]-x[i-1]
ans=0
for i in range(1,n):
  if a*d[i]>b:
    ans+=b
  else:
    ans+=a*d[i]
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict, deque
import math

# import copy
from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def solve():
    n, a, b = getList()
    nums = getList()

    ans = 0
    for i, j in zip(nums, nums[1:]):
        if a * (j - i) >= b:
            ans += b
        else:
            ans += a * (j - i)

    print(ans)

def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

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

Submission status: Accepted

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

if __name__ == '__main__':
    run()

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N, A, B = in_nn()
    X = list(in_nn())

    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)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np


N, A, B = map(int, input().split())
X = np.array(list(map(int, input().split())))
print(np.minimum((X[1:] - X[:-1]) * A, B).sum())

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
X = map(int, input().split())
curr = next(X)
ans = 0
for x in X:
    if (x - curr) * A <= B:
        ans += (x - curr) * A
    else:
        ans += B
    curr = x
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().split()))

dp = [float("inf") for _ in range(N)]
dp[0] = 0

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

P=0
Q=N-1
T=0

C=0
for _ in range(N-1):
    if T==0:
        P+=1
        J=A*(X[P]-X[P-1])
    else:
        Q-=1
        J=A*(X[Q+1]-X[Q])

    if J<=B:
        C+=J
    else:
        C+=B
        T^=1

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((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()))
L = [0] * n
for i in range(1, n):
    L[i] = min((x[i] - x[i-1]) * a, b)
print(sum(L))

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

print(s)

Submission status: Accepted

Solution code:
import numpy as np
import sys

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

if n == 2:
    print(min((x[1] - x[0]) * a, b))
    sys.exit()

left = 0
right = n - 1
curr = 0
cnt = 0
reverse = False


while left < right:
    if not reverse:
        if (x[curr + 1] - x[curr]) * a > (x[right] - x[right - 1]) * a + b:
            reverse = True
            cnt += b
            curr = right
            left += 1
        elif (x[curr + 1] - x[curr]) * a <= b:
            left += 1
            cnt += (x[curr + 1] - x[curr]) * a
            curr = left
        else:
            left += 1
            cnt += b
            curr = left
    else:
        if (x[curr] - x[curr - 1]) * a > (x[left + 1] - x[left]) * a + b:
            reverse = False
            cnt += b
            curr = left
            right -= 1
        elif (x[curr] - x[curr - 1]) * a <= b:
            right -= 1
            cnt += (x[curr] - x[curr - 1]) * a
            curr = right
        else:
            right -= 1
            cnt += b
            curr = right

print(cnt)

Submission status: Accepted

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

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:
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

N,A,B = map(int,readline().split())
X = list(map(int,readline().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())
dat = list(map(int, input().split()))
cost = 0
cur = dat[0]
for i in range(n):
    cost += min(b, a*(dat[i]-cur))
    cur = dat[i]
print(cost)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, a, b = ns()
    x = na()

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
xs = list(map(int, input().split()))
p = xs[0]
ans = 0
for x in xs[1:]:
    ans += (x-p)*a if (x-p)*a < b else b
    p = x
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):
  l=x[i]
  r=x[i+1]
  tmp=min(a*(r-l),b)
  ans+=tmp
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

dp = [float("INF") for _ in range(n)]
dp[0] = 0

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

print(dp[-1])

Submission status: Accepted

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

point = 0

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

print(point)

Submission status: Accepted

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

Submission status: Accepted

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

    ret = 0
    curr = next(X)
    for x in X:
        ret += min((x - curr) * A, B)
        curr = x
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 0
for i in range(1,n+1):
  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())
x = list(map(int,input().split()))
"""
率直に左からまわる.
"""
ans = 0
now = x[0]
for i in range(1, n):
	kyori = x[i]-now
	ans += min(a*kyori, b)
	now = x[i]
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,A,B = inpl()
a = inpl()
res = 0
for i in range(n-1):
    tmp = B
    if (a[i+1]-a[i]) * A <= B:
        tmp = (a[i+1]-a[i]) * A
    res += tmp
print(res)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

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

ans = 0
for i in range(N - 1):
    ans += min(B, A * (X[i + 1] - 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(1,N):
  step = min(A*(X[i]-X[i-1]),B)
  ans += step
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()))
ans = 0
old = X[0]
for i in range(1,N):
  a = (X[i]-old)*A
  ans += min(a,B)
  old = X[i]
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import *

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

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

l.sort(reverse=True)
ans = 10**18
walk = sum(l)

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

print(ans)

Submission status: Accepted

Solution code:
import sys
from collections import Counter
from collections import deque
import heapq
import math
import fractions
import bisect
import itertools
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,a,b=mp()
x=lmp()
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
def input(): return sys.stdin.readline().strip()

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, a, b = map(int, input().split())
    X = list(map(int, input().split()))

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


if __name__ == '__main__':
    resolve()

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:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n,a,b=map(int,readline().split())
    x=list(map(int,readline().split()))

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

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
X = list(map(int, input().split()))
D = [r - l for l, r in zip(X, X[1:])]

ans = sum(min(A * d, B) for d in D)
print(ans)

Submission status: Accepted

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

res = 0
cur = x_list[0]
for x in x_list[1:]:
    res += B if (x - cur) * A > B else (x-cur)*A
    cur = x
print(res)

Submission status: Accepted

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
import math
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
from collections import deque
inf = 10 ** 15
mod = 10 ** 9 + 7
n,a,b = map(int, input().split())
if b <= a:
    print(b*(n-1))
    sys.exit()
x = list(map(int, input().split()))
dp = [inf for i in range(n+1)] # iにつく時の最小の消費量
dp[1] = 0
for i in range(1,n):
    dp[i+1] = dp[i] + min((x[i]-x[i-1])*a, b)
print(dp[n])