Problem:


Score : 500 points

Problem Statement

There are N towns on a line running east-west.
The towns are numbered 1 through N, in order from west to east.
Each point on the line has a one-dimensional coordinate, and a point that is farther east has a greater coordinate value.
The coordinate of town i is X_i.

You are now at town 1, and you want to visit all the other towns.
You have two ways to travel:

Walk on the line.
Your fatigue level increases by A each time you travel a distance of 1, regardless of direction.

Teleport to any location of your choice.
Your fatigue level increases by B, regardless of the distance covered.

Find the minimum possible total increase of your fatigue level when you visit all the towns in these two ways.

Constraints

All input values are integers.

2≤N≤10^5

1≤X_i≤10^9

For all i(1≤i≤N-1), X_i<X_{i+1}.

1≤A≤10^9

1≤B≤10^9

Input

The input is given from Standard Input in the following format:

N A B
X_1 X_2 ... X_N

Output

Print the minimum possible total increase of your fatigue level when you visit all the towns.

Sample Input 1

4 2 5
1 2 5 7

Sample Output 1

11

From town 1, walk a distance of 1 to town 2, then teleport to town 3, then walk a distance of 2 to town 4.
The total increase of your fatigue level in this case is 2×1+5+2×2=11, which is the minimum possible value.

Sample Input 2

7 1 100
40 43 45 105 108 115 124

Sample Output 2

84

From town 1, walk all the way to town 7.
The total increase of your fatigue level in this case is 84, which is the minimum possible value.

Sample Input 3

7 1 2
24 35 40 68 72 99 103

Sample Output 3

12

Visit all the towns in any order by teleporting six times.
The total increase of your fatigue level in this case is 12, which is the minimum possible value.



Sample input:
4 2 5
1 2 5 7


Sample output:
11

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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
    else:
        ans += B
    curr = x
print(ans)

Submission status: Wrong Answer

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

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]
muki=1
l=0
r=n-1
now=0
ans=0
for i in range(n-1):
    if muki==1:
        if (x[now+1]-x[now])*a<=b:
            ans+=(x[now+1]-x[now])*a
            now+=1
            l+=1
        else:
            ans+=b
            now=r
            r-=1
            muki=-1
    elif muki==-1:
        if (x[now]-x[now-1])*a<=b:
            ans+=(x[now]-x[now-1])*a
            now-=1
            r-=1
        else:
            ans+=b
            now=l
            l+=1
            muki=1

print(ans)

Submission status: Wrong Answer

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]
    if f<t:
        ans+=A*f
    else:
        ans+=B
print(ans)
#print(["No","Yes"][cond])
#print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])
"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""

Submission status: Wrong Answer

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)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
xi = input().split()
visited = []
i = 0
p = 0
while i+1 < n:
    d = int(xi[i+1])- int(xi[i])
    if d*a > b:
        p += b
    else:
        p += d*2
    i += 1
print(p)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
xi = input().split()
visited = []
i = 0
p = 0
while i+1 < n:
    d = int(xi[i+1])- int(xi[i])
    if d*2 > b:
        p += b
    else:
        p += d*2
    i += 1
print(p)

Submission status: Wrong Answer

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

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

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

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

print(su)

Submission status: Wrong Answer

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

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

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

for i in range(a[0]-2):
	if a[2] >= c[i]*a[1]:
		su += a[2]
	else:
		su += c[i]*a[1]

print(su)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Time Limit Exceeded

Solution code:
#いろはコンテスト day2
import functools
import sys
from heapq import*

input=sys.stdin.readline

@functools.lru_cache(maxsize=None)
class UNION_FIND(object):
    def __init__(self,n):
        self.parent=[-1 for i in range(n)]
        
    def root(self,x):
        if self.parent[x]<0:
            return x
        else:
            self.parent[x]=self.root(self.parent[x])
            return self.parent[x]
 
    def size(self,x):
        return -self.parent[self.root(x)]
    def union(self,x,y):
        x=self.root(x)
        y=self.root(y)
        if x==y:
            return False
        if self.size(x)<self.size(y):
            x,y=y,x
        self.parent[x]+=self.parent[y]
        self.parent[y]=x
        return True
def compute_mst_kruskal(max_v, edges, flip):
    edges.sort(key=lambda x: x[2],reverse=flip)
    uf = UNION_FIND(max_v)
    mst = []
    for (a,b,c) in edges:
        if uf.root(a)!= uf.root(b):
            uf.union(a,b)
            mst.append((c))
    return mst
 
max_v, a,b=map(int,input().split()) 
*x,=map(int,input().split())

edges = []
for i in range(max_v):
    for j in range(max_v):
        heappush(edges,(i,j,min(abs(a*(x[i]-x[j])),b)))
mst = compute_mst_kruskal(max_v, edges , 0) #0が最小化
print(sum(mst))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys

def solve(dis_map, N):
    checked = set()
    cost = 0
    checked.add(0)
    remain_list = set(range(1, N))
    while (len(checked) != N):
        m = 0
        n = 0
        tmp_cost = 10**9 + 7
        for v in remain_list-checked:
            for u in checked:
                if tmp_cost > dis_map[v][u]:
                    tmp_cost = dis_map[v][u]
                    m = v
                    n = u
        checked.add(m)
        #remain_list.remove(m)
        #print(n, m)
        cost += tmp_cost
                
    return cost

N, A, B = list(map(int, sys.stdin.readline().strip().split(" ")))

x_list = list(map(int, sys.stdin.readline().strip().split(" ")))

dis_map = [[min(abs(x_list[i] - x_list[j]) * A, B) for i in range(N)] for j in range(N)]


print(solve(dis_map, N))

Submission status: Time Limit Exceeded

Solution code:
import sys

def solve(dis_map, N):
    node_list = list(range(N))
    checked = []
    cost = 0
    checked.append(0)

    remain_list = list(range(1, N))
    while (len(checked) != N):
        m = 0
        n = 0
        tmp_cost = 10**9 + 7
        for v in remain_list:
            for u in checked:
                if tmp_cost > dis_map[v][u]:
                    tmp_cost = dis_map[v][u]
                    m = v
                    n = u
        checked.append(m)
        remain_list.remove(m)
        #print(n, m)
        cost += tmp_cost
                
    return cost

N, A, B = list(map(int, sys.stdin.readline().strip().split(" ")))

x_list = list(map(int, sys.stdin.readline().strip().split(" ")))

dis_map = [[min(abs(x_list[i] - x_list[j]) * A, B) for i in range(N)] for j in range(N)]


print(solve(dis_map, N))

Submission status: Accepted

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

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

print(dp[-1])

Submission status: Accepted

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

ans = sum([min((xs[i] - xs[i - 1]) * a, b) for i in range(1, n)])
print(ans)

Submission status: Accepted

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

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:
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	n, a, b = tin()
	#s = input()	
	al=lin()
	pos=al[0]
	ret=0
	for np in al[1:]:
		ret += min(b, (np-pos)*a)
		pos = np
	return ret
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Accepted

Solution code:
import sys
# sys.setrecursionlimit(100000)


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


def input_int():
    return int(input())


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


def main():
    n, a, b = input_int_list()
    X = input_int_list()
    dp = [0] * (n)
    for i in range(1, n):
        dp[i] = min(dp[i - 1] + (X[i] - X[i - 1]) * a, dp[i - 1] + b)

    print(dp[n - 1])
    return


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    N, A, B = map(int, input().split())
    X = list(map(int, input().split()))
    dp = [float('inf')] * (N + 5)
    dp[0] = 0
    for i in range(1,N):
        dp[i] = dp[i-1] + min((X[i] - X[i-1]) * A, B)

    print(dp[N-1])

if __name__ == "__main__":
    main()

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


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(len(x)-1):
  walk_cost = a * (x[i+1]-x[i])
  if b < walk_cost:
    ans += b
  else:
    ans += walk_cost
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):
  # 町(i-1)から町iに行く方法を考えてみよう～～～
  toho = a * (x[i] - x[i-1])
  tele = b
  ans += min(toho, tele)
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):
    costa=(x[i+1]-x[i])*a
    ans+=min(b,costa)
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 x in X:
    dis = x - now
    tmp= min(A*dis , B)
    # print(tmp)
    ans += tmp
    now = 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):
    d = X[i+1]-X[i]
    if d * A < B:
        ans += d*A
    else:
        ans += B

print(ans)

Submission status: Accepted

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

dist = []
for i in range(n-1):
    dist.append(X[i+1]-X[i])
    
ans = 0
for d in dist:
    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()))
NewX = []
for i in range(N-1):
  NewX.append((X[i+1]-X[i])*A)
ans = 0
for i in NewX:
  ans+=min(i, B)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0

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

print(cnt)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

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

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

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

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

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()))
X.sort()

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 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, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
n,a,b = readInts()
X = readInts()
ans = 0
for i in range(1,n):
    ans += min(b, (X[i]-X[i-1])*a)
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 y in Y:
    if y*a <= b:
        ans += y*a
    else:
        ans += b
print(ans)

Submission status: Accepted

Solution code:
def LI():
    return list(map(int, input().split()))


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,A,B = map(int, input().split())
x = list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
n, a, b, *x = map(int, open(0).read().split())

now = x[0]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[1]:


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


# In[2]:


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


# In[ ]:

Submission status: Accepted

Solution code:
def main():
    N, A, B = map(int, input().split())
    X = list(map(int, input().split()))
 
    cost = 0
    for i in range(N-1):
        distance = abs(X[i] - X[i+1])
        if distance * A < B:
            cost += distance * A
        else:
            cost += B
    print(cost)
 
if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/python3
#coding: utf-8

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

ret = 0

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

print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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


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


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


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,a,b = list(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:
import sys

N, A, B = map(int, input().split())
X = list(map(int, sys.stdin.readline().rsplit()))

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

print(res)

Submission status: Accepted

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

vals = [float('inf')]*n
vals[0] = 0

c = queue.Queue()
c.put(1)

while not c.empty():
    d = c.get()
    if d == n:
        continue
    if b+vals[d-1] < vals[d]:
        vals[d] = b+vals[d-1]
    if a*(x[d]-x[d-1])+vals[d-1] < vals[d]:
        vals[d] = a*(x[d]-x[d-1])+vals[d-1]
    c.put(d+1)
print(vals[-1])

Submission status: Accepted

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

pin=lst[0]
ans=0

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

Submission status: Accepted

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

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

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):
  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
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()))

cost = 0
now = X[0]

for i in range(N):
    next = X[i]

    cost += min(A*(next-now),B)

    now = next

print(cost)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, A, B = map(int, readline().split())
    X = list(map(int, readline().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 = list(map(int,input().split()))

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

res = 0
tmp_i = X_list[0]
for x in X_list:
    a_fatigue = A * (x - tmp_i)
    b_fatigue = B
    tmp_fatigue = min(a_fatigue, b_fatigue)
    res += tmp_fatigue
    tmp_i = x
print(res)

Submission status: Accepted

Solution code:
import sys
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])*A >B:
        cnt+=B
    else:
        cnt +=A*(X[i+1]-X[i])
print(cnt)

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