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

town = list(map(int, input().split()))
diff = [0]*(N+1)
for i in range(1, N):
    diff[i] = town[i] - town[i-1]

sumz = 0
for i in range(1, N+1):
    if diff[i]*A > B:
        sumz += B
    else:
        sumz += diff[i]*A

print(sumz)

Submission status: Accepted

Solution code:
def main():
    n, a, b, *x = map(int, open(0).read().split())
    ans = 0
    it = iter(x)
    nw = it.__next__()
    for nx in it:
        ans += min(b, (nx - nw) * a)
        nw = nx

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    n, a, b, *x = map(int, open(0).read().split())
    ans = 0
    it = iter(x)
    nw = it.__next__()
    for nx in it:
        c = (nx - nw) * a
        if c > b:
            ans += b
        else:
            ans += c
        nw = nx

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    n, a, b, *x = map(int, open(0).read().split())
    ans = 0
    for i, j in zip(x, x[1:]):
        if a * (j - i) > b:
            ans += b
        else:
            ans += a * (j - i)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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


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

print(ans)

Submission status: Accepted

Solution code:
def main():
    n, a, b = list(map(int, input().split()))
    X = list(map(int, input().split()))
    INF = float('inf')
    dp = [0] * n
    for i in range(1, n):
        dp[i] = dp[i - 1] + min(a * (X[i] - X[i - 1]), b)
    print(dp[n - 1])

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

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N,A,B = IL()
X = IL()

MP = 0
NOW = X[0]
for x in X:
  MP += min((x-NOW)*A,B)
  NOW = x
print(MP)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
n,a,b=MI()
lis=LI()
ans=0
for i in range(n-1):
    ans+=min(a*(lis[i+1]-lis[i]),b)
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n,a,b=map(int,readline().split())
    x=list(map(int,readline().split()))
    y=[0]*(n-1)
    for i in range(n-1):
        y[i]=x[i+1]-x[i]

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

    print(ans)

if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
#from decimal import *

N, A, B = MAP()
X = LIST()

tmp = X[0]
ans = 0
for x in X:
	ans += min((x-tmp)*A, B)
	tmp = x

print(ans)

Submission status: Accepted

Solution code:

n,a,b = map(int,input().split())
lst = list(map(int,input().split()))
cost = 0
for i,value in enumerate(lst[1:]):
	#print(cost)
	diff = value -lst[i]
	cost += min(a*diff,b)
	
print(cost)

Submission status: Accepted

Solution code:
def move(X,N,A,B):
    output = 0
    for i in range(N-1):
        output += min(A*(X[i+1]-X[i]),B)

    return output

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

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)
 
# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):
        return -self.parents[self.find(x)]
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
 
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def group_count(self):
        return len(self.roots())
 
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
 
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
 
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
 
 
# ワーシャルフロイド (任意の2頂点の対に対して最短経路を求める)
# 計算量n^3 (nは頂点の数)
def warshall_floyd(d, n):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
 
 
# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d
 
# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
 
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])
 
    return arr
 
# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)
 
# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)
 
# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)
 
# 素数判定
 
 
 
# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []
 
    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P
 
# 同じものを含む順列
def permutation_with_duplicates(L):
 
    if L == []:
        return [[]]
 
    else:
        ret = []
 
        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))
 
        for i in S:
 
            data = L[:]
            data.remove(i)
 
            for j in permutation_with_duplicates(data):
                ret.append([i] + j)
 
        return ret
 
 
n,a,b=map(int,input().split())
l = list(map(int,input().split()))
ans=0
for i in range(1,n):
    ans+=min((l[i]-l[i-1])*a,b)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


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

print(ans)

Submission status: Accepted

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

import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)



def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1             # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n, a, b = mi()
    L = lmi()
    diff = [L[i] - L[i-1] for i in range(1, n)]
    cost = 0
    for elm in diff:
        cost += min(elm * a, 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 A * (X[i] - X[i-1]) < B:
        ans += A * (X[i] - X[i-1])
    else: ans += B
print(ans)

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

Solution code:
def abc052_d():
    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)

abc052_d()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import numpy as np
N, A, B = map(int, input().split())
X = np.array(list(map(int, input().split())))
diff = np.diff(X)
ans = 0
for d in diff:
    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(1, N):
  d = X[i] - X[i-1]
  ans += min(A*d, B)
  
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

dp=[float("inf")]*N
dp[0]=0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

#end = x[n - 1]
#lim = 10 ** 18
dp = [0] * n

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

ans = sum(dp)
print(ans)

Submission status: Accepted

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]

from collections import defaultdict, deque
from sys import exit
import heapq
import math
import copy
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N, A, B = mi()
X = li()

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

i=1
cnt=0
while i<n:
    if (x[i]-x[i-1])*a>b:
        cnt+=b
    else:
        cnt+=(x[i]-x[i-1])*a
    i+=1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

# x -----> x ----> x            y ----> y                z ----> z

# テレポートとテレポートの間を１グループとすると、各グループは独立している
# 行った道を引き返すことはない。基本的に左から右への移動で十分。

dp = [-1] * (N + 1)
dp[0], dp[1] = 0, 0

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

# print('dp', dp)
print(dp[-1])

Submission status: Accepted

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

if A >= B:
    print((N - 1) * B)
    exit()

# x -----> x ----> x            y ----> y                z ----> z

# テレポートとテレポートの間を１グループとすると、各グループは独立している
# 行った道を引き返すことはない。基本的に左から右への移動で十分。

dp = [-1] * (N + 1)
dp[0], dp[1] = 0, 0

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

# print('dp', dp)
print(dp[-1])

Submission status: Accepted

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
x = list(map(int,input().split()))
xdif = [x2-x1 for x1,x2 in zip(x,x[1:])]
ans = sum(dx*a if dx*a <b  else b for dx in xdif)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

x,a,b = map(int,input().split())
li = list(map(int,input().split()))
diff = []
for i in range(len(li)-1):
    c = li[i+1]-li[i]
    diff.append(c)
for i in range(len(diff)):
    diff[i] = min(diff[i]*a,b)
print(sum(diff))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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


dlist =[0]*(n-1)

for i in range(0,n-1):
    dlist[i] = (Alist[i+1] - Alist[i])*a

res = 0
for i in range(0,n-1):
    if dlist[i] > b:
        res += b
    else:
        res += dlist[i]

print(res)

Submission status: Accepted

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

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

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

print(res)

Submission status: Accepted

Solution code:
import sys


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


sys.setrecursionlimit(20000000)


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


if __name__ == "__main__":
    main()

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


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


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

res = 0
for i in range(N-1):
    if x[i+1]-x[i] > k:
        res += B
    else:
        res += (x[i+1]-x[i])*A
print(res)

Submission status: Accepted

Solution code:
nums1 = [int(e) for e in input().split()]
nums2 = [int(t) for t in input().split()]
ans = 0
N = nums1[0]
A = nums1[1]
B = nums1[2]
for i in range(0,N-1):
    if(nums2[i+1]-nums2[i])*A > B:
        ans+=B
    else:
        ans+=(nums2[i+1]-nums2[i])*A
print(ans)

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