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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for i, j in zip(x[:-1], x[1:]):
    c = min(A*(j-i), B)
    ans += c

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

if A >= B:
    print(B*(N-1))
else:
    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())
towns = list(map(int ,input().split()))
sum_e = 0
for i in range(1, N):
  dis = towns[i] - towns[i-1]
  if dis * A > B:
    sum_e += B
  else:
    sum_e += dis * A
print(sum_e)

Submission status: Accepted

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

diff = [X[n + 1] - X[n] for n in range(N - 1)]

ans = 0
for n in range(N - 1):
    if diff[n] * A > B:
        ans += B
    else:
        ans += diff[n] * A
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
# Input
s = [input() for i in range(2)]
 
N = int(s[0].split()[0])
A = int(s[0].split()[1])
B = int(s[0].split()[2])
X = s[1].split()
 
F = 0
 
# 疲労度の少ない方法を逐次選択する
for i in range(0, N-1):
    if A*(int(X[i+1]) - int(X[i])) >= B:
        F = F + B
    else:
        F = F + A*(int(X[i+1]) - int(X[i]))
 
# Output
print(F)

Submission status: Accepted

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

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

print(c)

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
X = [int(s) for s in input().split()]
ans = sum([min(A * (X[i+1] - X[i]), B) for i in range(N - 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 i in range(1,n):
    diff = x[i]-now
    if diff*a > b:
        ans += b
    else:
        ans += diff*a
    now = x[i]
    # print(ans)

print(ans)

Submission status: Accepted

Solution code:
N,A,B,*X=map(int,open(0).read().split());print(sum(min((y-x)*A,B)for x,y in zip(X,X[1:])))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
# N <= 10**5
# A, B <= 10**9
X = [int(x) for x in input().split()]
# X{i] <= 10**9
#
cost = 0
for i in range(N-1):
    d = X[i+1] - X[i]
    if d*A < B:
        #print(i, ":", d, "A")
        cost += d* A
    else:
        #print(i,":", d, "B")
        cost += B
print(cost)

Submission status: Accepted

Solution code:
def main():
    n,a,b = map(int,input().split())
    x = [int(x_) for x_ in input().split()]
    now = x[0]
    ans = 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)
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():

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

if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

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:
import sys
input=sys.stdin.readline
n,a,b=map(int,input().split())
x_list=list(map(int,input().split()))
l=b//a
ans=0
for i in range(1,n):
    d=x_list[i]-x_list[i-1]
    if d>l:
        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()))
y=[(x[i+1]-x[i])*a for i in range(n-1)]
hirou=0
for i in range(n-1):
  hirou+=min(y[i],b)
print(hirou)

Submission status: Accepted

Solution code:
N,A,B = map(int, input().strip().split(' '))
X = list(map(int, input().strip().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 sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

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

Submission status: Accepted

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

fatigue=0

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

print(fatigue)

Submission status: Accepted

Solution code:
# ABC052D - Walk and Teleport (ARC067D)
def main():
    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:
# ABC052D - Walk and Teleport (ARC067D)
import sys
input = sys.stdin.readline

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c, d = LI()
    print(max(a * b, c * d))
    return

#B
def B():
    _ = II()
    s = S()
    d = {}
    d["I"] = 1
    d["D"] = -1
    ans = 0
    now = 0
    for i in s:
        now += d[i]
        ans = max(ans, now)
    print(ans)
    return

#C
def C():
    def primes2(n):
        """https://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n/3035188#3035188"""
        """ Returns  a list of primes < n """
        sieve = [True] * (n//2)
        for i in range(3,int(n**0.5)+1,2):
            if sieve[i//2]:
                sieve[i*i//2::i] = [False] * ((n-i*i-1)//(2*i)+1)
        return [2] + [2*i+1 for i in range(1,n//2) if sieve[i]]
    n = II()
    prime = primes2(n+1)
    d = []
    for i in prime:
        b = n
        f = 0
        while b:
            b = b // i
            f += b
        d.append(f%mod)
    ans = 1
    for i in d:
        ans *= (i + 1)
        ans %= mod
    print(ans)
    return

#D
def D():
    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)
    return

#Solve
if __name__ == '__main__':
    D()

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

res = 0

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

from collections import defaultdict
import sys


def main():
    num, move, telepote = map(int, input().split())
    data = list(map(int, input().split()))

    ans = 0
    for i in range(num - 1):
        ans += min(telepote, move * (data[i + 1] - data[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()))
cost = 0
for i in range(n - 1):
    cost += min(a * (x[i + 1] - x[i]), b)
print(cost)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, A: int, B: int, X: "List[int]"):
    ret = 0
    cur = X[0]
    for i in range(1, N):
        ret += min(A * (X[i] - X[i - 1]), B)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    X = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A, B, X)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n,a,b = [int(i) for i in readline().split()]
x = [int(i) for i in readline().split()]

walk = [xj-xi for xi,xj in zip(x,x[1:]) if a*(xj-xi) < b]

w = sum(walk)*a
t = (n-1-len(walk))*b

print(t+w)

Submission status: Accepted

Solution code:
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import perm
# from scipy.misc import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

########

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

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

print(ans)

Submission status: Accepted

Solution code:
z=list(map(int,input().split()))
X=list(map(int,input().split()))
N,A,B=z[0],z[1],z[2]
a=1
p=0
while True:
    p+=min((X[a]-X[a-1])*A,B)
    a+=1
    if a==N:
        break
print(p)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n, a, b = map(int, input().split(" "))
    x = list(map(int, input().split(" ")))
    fatigue = 0
    current = x[0]

    for x_i in x[1:]:
        fatigue = fatigue + min((x_i - current) * a, b)
        current = x_i
    print(fatigue)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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((X[i] - X[i - 1]) * A, B)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

sum_cost = 0
for n in range(1, N):
	cost = (X[n] - X[n - 1]) * A
	if B < cost:
		sum_cost += B
	else:
		sum_cost += cost
	#print(sum_cost)
print(sum_cost)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
x = list(map(int, input().split()))
ans = 0
for x1, x2 in zip(x, x[1:]):
  ans += min(a * (x2 - x1), 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:


def read_input():
    n, a, b = map(int, input().split())
    xlist = list(map(int, input().split()))
    return n, a, b, xlist


def submit():
    n, a, b, xlist = read_input()

    tired = 0

    for xs, xe in zip(xlist, xlist[1:]):
        dist = xe - xs

        if dist*a < b:
            tired += dist*a
        else:
            tired += b

    print(tired)
    return


if __name__ == '__main__':
    submit()

Submission status: Accepted

Solution code:
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

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

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

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n,a,b=LI()
  l=LI()

  sm=0
  for i in range(n-1):
    x=l[i+1]-l[i]

    if x*a<b:
      sm+=x*a
    else:
      sm+=b

  return sm

print(main())

Submission status: Accepted

Solution code:
# 歩く部分は連結。左から右としてよい。
# 結局ワープも左から右としてよい。

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

n, a, b = [ int(v) for v in input().split() ]
town_list = [ int(v) for v in input().split() ]
fatigue_list = [ 0 for i in range(n) ]

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

Submission status: Accepted

Solution code:
import itertools

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

ans = sum(min(a * abs(p - q), b) for p, q in zip(x, x[1:]))
print(ans)

Submission status: Accepted

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

print(sum)

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
now=0
ans=0
for x in map(int,input().split()):
    if now!=0:
        if (x-now)*A>B:
            ans+=B
        else:
            ans+=(x-now)*A
    now=x
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

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

X.sort()
ans = (X[-1]-X[0])*A
for i in range(N-1):
    if (X[i+1] - X[i])*A > B:
        ans += B - (X[i+1] - X[i])*A
print(ans)

Submission status: Accepted

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n , a, b = f()
    x = f()
    dis = [x[i+1] - x[i] for i in range(n-1)]


    ans = 0
    for i in dis:
        if i*a <= b:
            ans += i * a
        else:
            ans += b
    
    print(ans)


solve()

Submission status: Accepted

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

for i in range(0,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 = [int(z) for z in input().split()]
ans = 0

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


print(ans)

Submission status: Accepted

Solution code:
N,A,B = [ int(it) for it in input().split() ]
li = [ int(it) for it in input().split() ]
s = 0
for i in range(len(li)-1):
  d = li[i+1] - li[i]
  if (A*d<B):
    ds = d*A
  else:
    ds = B
  s+=ds
print (s)

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 = [int(i) for i in input().split()]

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

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
n, a, b = map(int,input().split())
*p, = map(int,input().split())
l = []
#print(p)
for i in range(1,n):
  w = (p[i]-p[i-1])*a 
  if w >= b:
    l.append(b)
  else:
    l.append(w)
#print(l)
print(sum(l))

Submission status: Accepted

Solution code:
import sys

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

    diff = [0 for _ in range(N-1)]
    for i in range(N-1):
        diff[i] = X[i+1] - X[i]

    ans = 0
    for d in diff:
        ans += min(A*d, B)

    return ans


if __name__ == '__main__':
    print(main())

Submission status: Accepted

Solution code:
def walk_and_teleport(N: int, A: int, B: int, X: list)->int:
    pos = X[0]
    cost = 0

    for x in X[1:]:
        cost += min(A * (x - pos), B)
        pos = x

    return cost


if __name__ == "__main__":
    N, A, B = map(int, input().split())
    X = [int(s) for s in input().split()]
    ans = walk_and_teleport(N, A, B, X)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

fatigue = 0

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

print(fatigue)

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if a > b:
    print(b * (n - 1))
    exit()

d = b // a + 1

ans = 0
for i in range(n-1):
    temp = x[i+1] - x[i]
    if temp >= d:
        ans += b
    else:
        ans += temp * a

print(ans)

Submission status: Accepted

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