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

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(x):
    print(x,file=sys.stderr)
def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())

#繰り返し自乗法だよ
#これはnのp乗をmで割ったあまりをだすよ
def modular_w_binary_method (n,m,p):
    ans=1 if n>0 else 0
    while(p>0):
        if p%2==1:
            ans=(ans*n)%m
        n=(n**2)%m
        p//=2
    return ans
#mod上でのaの逆元を出すよ
"""
    フェルマーの小定理より a**(p)%p==a isTrue
    これを利用すれば a**(p-2)%p==a**(-1) isTrue
    元と逆元とをかけてpで割れば1が余るよ！
"""
def modular_inverse(a,prime):
    return(modular_w_binary_method(a,prime,prime-2))
#逆元を使うと容易に頑張れるｃ
def conbination(n,a,mod=10**9+7):
    #cはイラない
    res=1 
    for s in range(a):
        res=(res*(n-s)*(modular_inverse(s+1,mod)))%mod

        
    return res
#操作から作れるものの組み合わせは何個かー＞同じものでも違う方法で構成できるかから考える方法もある
"""
"""

#solution:

#input
N,A,B=pin()
X=list(pin())
t=(B+1)//A
ans=0
for i in range(1,N):
    f=X[i]-X[i-1]
    ans+=min(A*f,B)
print(ans)
#print(["No","Yes"][cond])
#print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])
"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""

Submission status: Accepted

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

ans = 0

for i, x in enumerate(X):
    if i == N-1:
        continue
    if (X[i+1] - x) * A > B:
        ans += B
    else:
        ans += (X[i+1] - x) * A

print(ans)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
n,a,b = map(int,readline().split())
x = list(map(int,readline().split()))

ans = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for i in range(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()))

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, a, b, *x = map(int, open(0).read().split())
ans = 0
t = x.pop(0)
for i in x:
    if a*(i-t)>b: ans += b
    else: ans += a*(i-t)
    t = i
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

dp=[0]*n

for i in range(1,n):
    prev=x[i-1]
    nxt =x[i]
    walk = a*(nxt-prev)
    tele = b

    if walk > tele:
        dp[i] = dp[i-1] + tele
    else:
        dp[i] = dp[i-1] + walk

print(dp[n-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect
def MLI():
    return map(int, open(0).read().split())

def main():
    N, A, B, *X = MLI()
    
    ret = 0
    for s, e in zip(X[:-1], X[1:]):
        diff = e - s
        if diff * A < B:
            ret += diff * A
        else:
            ret += B
            
    print(ret)
            

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):
    d = X[i+1]-X[i]
    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()))

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
prev_x = X[0]
for i in range(1, N):
    walk_cost = A * (X[i] - prev_x)
    if walk_cost < B:
        ans += walk_cost
    else:
        ans += B
    prev_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((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
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()))
X = [i-X[0] for i in X]
X.pop(0)
now = 0
count = 0
for i in X:
    if A*(i-now) < B:
        count += A*(i-now)
    else:
        count += B
    now = i
print(count)

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

print(ans)

Submission status: Accepted

Solution code:
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
#https://atcoder.jp/contests/abc114/tasks/abc114_c
#C - 755
"""
need to consider the case that ticket is not enough to lower everything
"""

N = gi()
A = gi()
B = gi()

X = [0] * N
for i in range(N):
    X[i] = gi()

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

for i in range(1, N):
    x = X[i] - X[i - 1]
    ans += min((x * 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(1, N):
    x = X[i] - X[i - 1]
    ans += min((x * 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(1, N):
    x = X[i] - X[i - 1]
    
    if (x * A) >= B:
        ans += B
    else:
        ans += x * 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(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, *X = map(int, open(0).read().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:
class UnionFind():
   # 作りたい要素数nで初期化
   # 使用するインスタンス変数の初期化
   def __init__(self, n):
       self.n = n
       # root[x]<0ならそのノードが根かつその値が木の要素数
       # rootノードでその木の要素数を記録する
       self.root = [-1]*(n+1)
       # 木をくっつける時にアンバランスにならないように調整する
       self.rnk = [0]*(n+1)
   # ノードxのrootノードを見つける
   def Find_Root(self, x):
       if(self.root[x] < 0):
           return x
       else:
           # ここで代入しておくことで、後の繰り返しを避ける
           self.root[x] = self.Find_Root(self.root[x])
           return self.root[x]
   # 木の併合、入力は併合したい各ノード
   def Unite(self, x, y):
       # 入力ノードのrootノードを見つける
       x = self.Find_Root(x)
       y = self.Find_Root(y)
       # すでに同じ木に属していた場合
       if(x == y):
           return
       # 違う木に属していた場合rnkを見てくっつける方を決める
       elif(self.rnk[x] > self.rnk[y]):
           self.root[x] += self.root[y]
           self.root[y] = x
       else:
           self.root[y] += self.root[x]
           self.root[x] = y
           # rnkが同じ（深さに差がない場合）は1増やす
           if(self.rnk[x] == self.rnk[y]):
               self.rnk[y] += 1
   # xとyが同じグループに属するか判断
   def isSameGroup(self, x, y):
       return self.Find_Root(x) == self.Find_Root(y)
   # ノードxが属する木のサイズを返す
   def Count(self, x):
       return -self.root[self.Find_Root(x)]
n,a,b=map(int,input().split())
x=list(map(int,input().split()))
h=UnionFind(n)
d=[0]*(2*n-2)
for i in range(n-1):
    d[i]=[i,i+1,min(b,a*(x[i+1]-x[i]))]
    d[i+n-1]=[i,n-1,b]
d.sort(key=lambda x:x[2])
cnt = 0
for i in d:
    if not h.isSameGroup(i[0],i[1]):
        h.Unite(i[0],i[1])
        cnt += i[2]
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(N-1):
    d = X[i+1]-X[i]
    ans += B if A*d>B else A*d
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

l = [int(i) for i in 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:
import math
import random
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
N,A,B = map(int,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 += B
    else:
        ans += (X[i+1]-X[i])*A
print(ans)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())  # N個の町, 1移動するたびにA, テレポートのB
X = list(map(int, input().split()))
ans = 0
now_x = X[0]
for i in range(1, N):
    ans += min((X[i] - now_x) * A, B)
    now_x = X[i]
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

# o <-tel-> o --walk-- 0 -- walk-- o <=tel-> ...
# 左から順にa,b最小コストを選択
print(sum(min((after - prev) * a, b) for prev, after in zip(x, x[1:])))

# http://xxxasdfghjk999.hatenablog.jp/entry/2018/07/29/214705
# 最小全域木だとTLEする
# 徒歩区間を連結できるので、貪欲に決まる

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)

def main():
    n, a, b = map(int, input().strip().split())
    x = list(map(int, input().strip().split()))
    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:
from math import ceil

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

now = x_array[0]
ans = 0
for x in x_array[1:]:
    if abs(x-now)*a > b:
        ans += b
    else:
        ans += abs(now-x)*a
    now = x
print(ans)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
X = list(map(int, input().split()))
d = [abs(j - i) for i, j in zip(X[:-1], X[1:])]
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())
xn = [int(i) for i in input().split()]
dpn = [10**9+7]*n
dpn[0] = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math

def input():
    return sys.stdin.readline()[:-1]

def main():
    N, A, B = map(int,input().split())
    X = sorted(list(map(int,input().split())))
    Y = [0 for k in range(N)]
    for k in range(1,N):
        Y[k-1] = X[k] - X[k-1]
    Y = sorted(Y)
    ans = 0
    for e in Y:
        ans += min(e*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(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 a,b in zip(X,X[1:]):
    ans += min((b-a)*A, B)
print(ans)

Submission status: Accepted

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    n, a, b = list(map(int, input().rstrip('\n').split()))
    x = list(map(int, input().rstrip('\n').split()))
    lp = x[0]
    t = 0
    for i in range(1, n):
        if (x[i] - lp) * a <= b:
            t += ((x[i] - lp) * a)
        else:
            t += b
        lp = x[i]
    print(t)


if __name__ == '__main__':
    slove()

Submission status: Accepted

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


ans=0
for i in range(1,n):
    aa=(x[i]-x[i-1])*a
    ans+=min(aa,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):
  if(i != 0):
    dif = X[i]-X[i-1]
    ans += min(dif*A,B)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import os
N,A,B = map(int,input().split())
X = list(map(int,input().split()))
tired = 0
cur = X[0]
for x in X:
    if A*(x - cur) <= B:
        tired += A*(x - cur)
    else:
        tired += B
    cur = x
print(tired)

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())
x = list(map(int, input().split()))
vx = [0] * (n-1)
for i in range(n-1):
    vx[i] = x[i+1] - x[i] 

vx.sort()
ans = 0

for i in range(n-1):
    wf = vx[i] * a
    if wf > b:
        ans += b * (n - i - 1)
        break
    ans += wf

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
N, A, B = [int(_) for _ in stdin.readline().rstrip().split()]
X = [int(_) for _ 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):
    tmp = A *(X[i+1]-X[i])
    ans += min(tmp,B)

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N,A,B=map(int,input().split())

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

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

print(count)

Submission status: Accepted

Solution code:
N,A,B = [int(x) for x in input().split()]
X = [int(x) for x in input().split()]
cost = 0
for ind,x in enumerate(X[:-1]):
    cost += min((X[ind+1]-x)*A,B)
print(cost)

Submission status: Accepted

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

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

print(sum(ans))

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in range(n-1):
    if (X[i+1]-X[i])*a>=b:
        hirou+=b
    else:
        hirou+=(X[i+1]-X[i])*a

print(hirou)

Submission status: Accepted

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

    print(fatigue)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
# 2019/09/03

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

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

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

print(min(ans1, ans2))

Submission status: Accepted

Solution code:
#import pysnooper
import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

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

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

main()

Submission status: Accepted

Solution code:
N, A, B, *X = map(int, open(0).read().split())
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())
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:
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline

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

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

print(ans)

Submission status: Accepted

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
##############################

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

hi = 0

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

print(hi)

Submission status: Accepted

Solution code:
# ABC052D - Walk and Teleport (ARC067D)
def main():
    # choose A * dist(i, j) or B greedily
    N, A, B = tuple(map(int, input().split()))
    X = tuple(map(int, input().split()))
    ans = sum(min(A * (j - i), B) for i, j in zip(X, X[1:]))
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# ARC067D - Walk and Teleport (ABC052D)
def main():
    # choose A * dist(i, j) or B greedily
    N, A, B = tuple(map(int, input().split()))
    X = tuple(map(int, input().split()))
    ans = sum(min(A * (j - i), B) for i, j in zip(X, X[1:]))
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# ARC067D - Walk and Teleport (ABC052D)
def main():
    # choose A * dist[i, j] or B
    N, A, B = tuple(map(int, input().split()))
    X = tuple(map(int, input().split()))
    D = [j - i for i, j in zip(X, X[1:])]  # distance
    ans = sum(min(A * d, B) for d in D)
    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(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(" ")))
Xs = list(map(int, input().split(" ")))
Xs.sort()
ans = 0
for i in range(1,N ):
    ans += min (B,abs(Xs[i] - Xs[i-1])* A )

print(ans)

Submission status: Accepted

Solution code:
import copy
import sys
import math

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


def listtodict(a):
	b = {}
	for i in a:
		try:
			b[i] += 1
		except:
			b[i] = 1
	return b

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

main()