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:

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop

n,a,b=n1()
X=n1()

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

Submission status: Accepted

Solution code:
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

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

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]

    if b >= a*dist:
        ans += a*dist
    else:
        ans += b

print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？


n,a,b=mii()
arr=limii()
cnt=0
for i in range(n-1):
    if (arr[i+1]-arr[i])*a>b:
        cnt+=b
    else:
        cnt+=(arr[i+1]-arr[i])*a
print(cnt)

Submission status: Accepted

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

fatigue = [0] * n

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

print(fatigue[n - 1])

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, len(x)):
    a_c = (x[i]-x[i-1])*a
    b_c = b
    if a_c > b_c:
        res += b_c
    else:
        res += a_c

print(res)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
x = list(map(int, input().split()))
diff = []
for i in range(n-1):
    diff.append(x[i+1]-x[i])
ans = 0
for i in diff:
    ans += min(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
for i in range(n-1):
    d = x[i+1] - x[i]
    if a * d < b:
        ans += a * d
    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((x[i + 1] - x[i]) * a, b)
print(ans)

Submission status: Accepted

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

ans = 0
for x, y in zip(City, City[1:]):
    if y - x <= d:
        ans += (y - x) * A
    else:
        ans += B
print(ans)

Submission status: Accepted

Solution code:
import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        N,A,B=map(int,input().split())
        X=list(map(int,input().split()))
        if A>=B:
            return (N-1)*B
        else:
            ans=0
            merit=math.ceil(B/A)
            for i in range(N-1):
                d=X[i+1]-X[i]
                if d>=merit:
                    ans+=B
                else:
                    ans+=A*d
            return ans
    print(main())


    
resolve()

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10 ** 7)

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys

N, A, B = map(int, sys.stdin.readline().strip().split())
X = list(map(int, sys.stdin.readline().strip().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,   = map(int, input().split())

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

print(ans)

Submission status: Accepted

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

A = np.array(x)
walk_d = np.diff(A, n=1) * a
ans = 0
for num in walk_d:
  ans += min(num,b)
print(ans)

Submission status: Accepted

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

cost=0
tp=n-1
for i in range(n-1):
    walk=(x[i+1]-x[i])*a
    if walk<b:
        cost+=walk
        tp-=1

cost+=tp*b
print(cost)

Submission status: Accepted

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

Submission status: Accepted

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import math
n,a,b = map(int,input().split())
li = list(map(int,input().split()))
sakai = math.ceil(b/a)
ans = 0
for i,l in enumerate(li):
    if i == 0:
        continue
    #print(ans,i,l-li[i-1],sakai)
    if l-li[i-1]>=sakai:
        ans += b
    else:
        ans += a*(l-li[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:
n, a, b = map(int, input().split())
x = list(map(int, input().split()))

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, a, b = map(int, readline().split())
x = list(map(int, readline().split()))
ans = 0
for bf, af in zip(x, x[1:]):
    ans += min((af - bf) * a, b)
print(ans)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/arc067/tasks/arc067_b

n, a, b = map(int, input().split())
nums = [int(i) for i in input().split()]

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
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:
def resolve():
    '''
    code here
    '''
    N, A, B = [int(item) for item in input().split()]
    X_list = [int(item) for item in input().split()]

    memo = 0

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

if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

d = [x[i+1] - x[i] for i in range(n-1)]

s = 0

for i in d:
    if a*i < b:
        s += a*i
    else:
        s += b

print(s)

Submission status: Accepted

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


def solve(N: int, A: int, B: int, X: "List[int]"):
    Sum = 0
    for n in range(1, N):
        walk_cost = (X[n] - X[n-1]) * A
        if walk_cost > B:
            Sum += B
        else:
            Sum += walk_cost
    print(Sum)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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]"
    solve(N, A, B, X)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
X = [int(x) for x in input().split()]
tired = 0
x_ = X[0]
for x in X[1:]:
    d = x - x_
    tired += b if b <= d * a else d * a
    x_ = x
print(tired)

Submission status: Accepted

Solution code:
import sys

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


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

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

    res = 0
    for d in dist:
        if d * a <= b:
            res += d * a
        else:
            res += b

    print(res)


if __name__ == '__main__':
    resolve()

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

Submission status: Accepted

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


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


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N, A, B = MI()
    X = LI()
    ans = 0

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

Submission status: Accepted

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

# print(N, A, B)
# print(X)

INF = int(1e18)

dp = [INF for _ in range(N + 1)]
dp[0] = 0

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

print(dp[N - 1])


# cost = 0
# index_now = 1
# index_prev = 0
# loc_now = X[0]

# while index_now < N:
#     # print(index_now)

#     # 次の地点まで歩く
#     cost_walk = (X[index_now] - loc_now) * A
#     # 次の地点にワープする
#     cost_warp = B
#     print(index_now, cost_walk, cost_warp)

#     index_now += 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(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())
lis=list(map(int,input().split()))

ans=0

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
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])
    
exh = 0
li = b / a
for i in l:
    if i > li:
        exh += b
    else:
        exh += a*i
        
print(exh)

Submission status: Accepted

Solution code:
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


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


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

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

    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())
X=list(map(int,input().split()))
Y=[ X[i+1]-X[i] for i in range(N-1)]
ans=0

for move in Y:
  ans += min(move*A,B)
  
print(ans)

Submission status: Accepted

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

for move in Y:
  ans += min(move*A,B)
  
print(ans)

Submission status: Accepted

Solution code:
###### Importing Libraries ######
import math
import operator as op
from functools import reduce
from fractions import Fraction as frac
#################################
##### User defined function #####

############ NCR ###############
def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer / denom
    
############ READ ###############
def rd(p):
    if(p==0):
        return input()
    if(p==1):
        return int(input())
    if(p==2):
        return map(int,input().split())
    if(p==3):
        return list(map(int,input().split()))


############ DSU ###############
global par
# par=[-1 for i in range(100001)]
# t=rd(1)
def find(u):
    if(par[u]<0):
        return u
    else:
        return find(par[u])
def uni(x,y):
    u=find(x)
    v=find(y)
    if u==v:
        return
    if(par[u]<par[v]):
        par[u]+=par[v]
        par[v]=u
    else:    
        par[v]+=par[u]
        par[u]=v
################################        
        

t=1
for term in range(1,t+1):
    n,a,b=rd(2)
    X=rd(3)
    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()))

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

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

Submission status: Accepted

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

print(sum(min(b, (x[i+1] - x[i]) * a) for i in range(n-1)))

Submission status: Accepted

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

sum=0

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from sys import stdin 
n,a,b = [int(x) for x in stdin.readline().rstrip().split()]
x = [int(x) for x in stdin.readline().rstrip().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(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())
ans=0
l=list(map(int,input().split()))
p=l[0]
for i in l[1:] :
    ans+=min(a*(-p+i),b)
    p=i
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()))

data=[]
for i in range(0,N-1):
    data.append(A*(X[i+1]-X[i]))

data.sort(reverse=True)

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

Submission status: Accepted

Solution code:
import numpy as np
N, A, B = map(int, input().split())
X = np.array(list(map(int, input().split())))
X -= X[0]
D = X[1:]-X[:-1]
ans = np.sum(np.minimum(D*A, B))
print(ans)

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

cur = x[0]
count = 0
for i in x[1:]:
    count += min((i - cur) * a, b)
    cur = i

print(count)

Submission status: Accepted

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

n, a, b = map(int, input().split())
x = list(map(int, input().split()))
k = math.floor(b / a)
ans = 0
for i in range(1, n):
    if k >= x[i] - x[i - 1]:
        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
for k in range(N-1):
    ans += min((X[k+1]-X[k])*A,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):
    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, *X = map(int, open(0).read().split())
ans = 0
cur = X[0]
for i in range(1, N):
    x = X[i]
    cost_a = (x - cur) * A
    ans += min(cost_a, B)
    cur = 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 a*(x[i+1] - x[i]) <= b:
		ans += a*(x[i+1] - x[i])
	else:
		ans += b
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from itertools import chain

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

def main():
    for i in range(1,N):
        yield min((X[i] - X[i-1])*A, B)


print(sum(main()))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

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 fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
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 = sys.maxsize
mod = 10 ** 9 + 7

n, a, b = MAP()
x = LIST()
ans = 0
for i in range(1, n):
    tmp = x[i] - x[i - 1]
    if tmp * a < b:
        ans += tmp * 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(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()))
c=0
for i in range(n-1):
    if a*(x[i+1]-x[i])>b:
        c+=b
    else:
        c+=a*(x[i+1]-x[i])
print(c)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
ans = 0
current = 0
for x in map(int,input().split()):
    if current>0:
        ans += min(a*(x-current),b)
    current=x
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
N,A,B = [int(x) for x in stdin.readline().rstrip().split()]
X = [int(x) for x in stdin.readline().rstrip().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:
N, A, B = map(int, input().split())

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

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

print(fatigue)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
kaz , a , b = map(int,input().split(" "))
cou = 0
mac = list(map(int,input().split(" ")))

for i in range(kaz-1):
    if (mac[i+1] - mac[i])*a > b:
        cou += b
    else:
        cou += (mac[i+1] - mac[i])*a
        
print(cou)

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

Submission status: Accepted

Solution code:

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

c = 0
s = l[0]
for i in l:
    c += min((i-s)*a, b)
    s = i
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(1,n):
    if (x[i]-x[i-1])*a>=b:
        ans+=b
    else:
        ans+=(x[i]-x[i-1])*a
print(ans)