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]=[int(x) for x in raw_input().split()]
X=[int(x) for x in raw_input().split()]
W=[]
for i in range(N-1):
    W.append( min ((X[i+1]-X[i])*A,B))
print sum(W)

Submission status: Accepted

Solution code:
import itertools,math,bisect,pprint,sys
n, a, b = map(int, raw_input().split())
x = map(int, raw_input().split())
res = 0
for i in range(n-1):
    c = (x[i+1]-x[i])*a
    if c > b:
        res += b
    else:
        res += c
print res

Submission status: Accepted

Solution code:
def iter2(it):
    x = iter(it)
    before = next(x)
    for item in x:
        yield before, item
        before = item

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

costs = (min(B, A*(x2-x1)) for x1, x2 in iter2(xs))
print(sum(costs))

Submission status: Accepted

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

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

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


def main():
    n,a,b = LI()
    r = 0
    x = LI()

    t = x[0]
    x.sort()
    i = x.index(t)
    if i == n-1 or i == 0:
        for j in range(n-1):
            if (x[j+1] - x[j]) * a < b:
                r += (x[j+1] - x[j]) * a
            else:
                r += b
        return r

    if (x[i+1]-x[0])*a < b:
        r += ((t - x[0]) + (x[i+1] - x[0]))*a
        for j in range(i+2,n):
            if (x[j] - x[j-1]) * a < b:
                r += (x[j] - x[j-1]) * a
            else:
                r += b
        return r
    if (x[-1]-x[i-1])*a < b:
        r += ((x[-1] - t) + (x[-1] - x[i-1]))*a
        for j in range(i-1):
            if (x[j+1] - x[j]) * a < b:
                r += (x[j+1] - x[j]) * a
            else:
                r += b
        return r

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

    return r


print(main())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, a, b = map(int, raw_input().split())
x = map(int, raw_input().split())
y = [x[i+1] - x[i] for i in range(n-1)]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b=[int(i) for i in input().split()]
x=[int(i) for i in input().split()]
ans=chk=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, raw_input().split())
X = map(int, raw_input().split())

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

nums=list(map(int,input().split))
tmp=nums[0]
ans=0
for num in nums[1:]:
  if (nuw-tmp)*a<=b: 
    ans+=(num-tmp!)*a
  else:
    ans+=b
  tmp=num

print(ans)

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
ans = 0
for i in range(n):
  v = int(input())
  if i:
    ans += min(a * (v - last), b);
  last = v
print(ans)

Submission status: Runtime Error

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

import numpy as np
from scipy.sparse.csgraph import minimum_spanning_tree
ans = np.sum(minimum_spanning_tree(edges))
print(int(ans))

Submission status: Runtime Error

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

Submission status: Runtime Error

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)

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

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: Runtime Error

Solution code:

def main():
    [n,a,b] = list(map(int,input().split()))
    m = list(map(int,input().split()))
    cost = 0
    for i in range(1,n+1):
        cost += min(a*(m[i]-m[i-1]), b)
    print(cost)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:

def main():
    [n,a,b] = list(map(int,input().split()))
    m = list(map(int,input().split()))
    cost = 0
    for i in range(1,n+1):
        cost += min(a*(m[i]-m[i-1]), b)
    print(cost)


if __name__ == "__main__":
    import sys
    import os
    if len(sys.argv) > 1:
        if sys.argv[1] == "-d":
            filename = "input1.txt"
            fd = os.open(filename, os.O_RDONLY)
            os.dup2(fd, sys.stdin.fileno())
            main()
    else:
        main()