Problem:


Score : 100 points

Problem Statement

There is a hotel with the following accommodation fee:

X yen (the currency of Japan) per night, for the first K nights

Y yen per night, for the (K+1)-th and subsequent nights

Tak is staying at this hotel for N consecutive nights.
Find his total accommodation fee.

Constraints

1 \leq N, K \leq 10000

1 \leq Y < X \leq 10000

N,\,K,\,X,\,Y are integers.

Input

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

N
K
X
Y

Output

Print Tak's total accommodation fee.

Sample Input 1

5
3
10000
9000

Sample Output 1

48000

The accommodation fee is as follows:

10000 yen for the 1-st night

10000 yen for the 2-nd night

10000 yen for the 3-rd night

9000 yen for the 4-th night

9000 yen for the 5-th night

Thus, the total is 48000 yen.

Sample Input 2

2
3
10000
9000

Sample Output 2

20000



Sample input:
5
3
10000
9000


Sample output:
48000

Submission status: Runtime Error

Solution code:
# ABC 044 A - 高橋君とホテルイージー / Tak and Hotels (ABC Edit)
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

if K > N:
    ans = N * X
elif N > K:
    ans = K * X
    ans +=(N-K)* Y

print( ans )

Submission status: Runtime Error

Solution code:
n = int(input())
k = int(input())
x = int(input())
y = int(input())

for i in range(n):
  if i == k+1:
    ans += y;
  else:
    ans += x
    
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
s = int(input())

flag = False

if s == n:
  print(n+1)
  exit()

def chk(b, n):
  if n//b == 0:
    return n
  else:
    return chk(b,n//b) + n%b

for b in range(2, int(n**0.5)+1):
  if chk(b, n) == s:
    print(b)
    flag = True
    exit()

for i in range(int(n**0.5), 0, -1):
  b = (n-s)//i + 1
  if chk(b, n) == s:
    print(b)
    flag = True
    exit()

if flag == False:
  print(-1)

Submission status: Runtime Error

Solution code:
n, k, x, y = map(int, input().split())
print(min(n, k)* x + max(0, n - k) * y);

Submission status: Runtime Error

Solution code:
n, a = map(int, input().split())
x = list(map(int, input().split()))
dp = [[[0]*(50*n+1) for _ in range(n+1)] for _ in range(n+1)]
for i in range(n+1):
    for j in range(n+1):
        for k in range(50*n+1):
            if i == 0 and j == 0 and k == 0:
                dp[i][j][k] = 1
            elif i and k < x[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            elif i and j and k >= x[i-1]:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i-1]]
ans = 0
for j in range(1, n+1):
    ans += dp[n][j][a*j]
print(ans)

Submission status: Runtime Error

Solution code:
N, a = map(int, input().split())
x = list(map(int, input().split()))
dp = [[[0]*(50*N+1) for _ in range(N+1)] for _ in range(N+1)]
for i in range(N+1):
    for j in range(N+1):
        for k in range(50*N+1):
            if i == 0 and j == 0 and k == 0:
                dp[i][j][k] = 1
            elif i and k < x[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            elif i and j and k >= x[i-1]:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i-1]]
ans = 0
for j in range(1, N+1):
    ans += dp[N][j][a*j]
print(ans)

Submission status: Runtime Error

Solution code:
N, a = map(int, input().split())
*x, = (map(int, input().split()))
dp = [[[0]*(50*N+1) for _ in range(N+1)] for i in range(N+1)]
for i in range(N+1):
    for j in range(N+1):
        for k in range(50*N+1):
            if i == j == k == 0:
                dp[i][j][k] = 1
            elif i and k < x[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            elif i and j and k >= x[i-1]:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i-1]]
ans = 0
for j in range(1, N+1):
    ans += dp[N][j][a*j]
print(ans)

Submission status: Runtime Error

Solution code:
N, a = map(int, input().split())
x = list(map(int, input().split()))
dp = [[[0]*(50*N+1) for _ in range(N+1)] for i in range(N+1)]
for i in range(N+1):
    for j in range(N+1):
        for k in range(50*N+1):
            if i == j == k == 0:
                dp[i][j][k] = 1
            elif i and k < x[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            elif i and j and k >= x[i-1]:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i-1]]
ans = 0
for j in range(1, N+1):
    ans += dp[N][j][a*j]
print(ans)

Submission status: Runtime Error

Solution code:
N, a = map(int, input().split())
x = list(map(int, input().split()))
dp = [[[0]*(50*N+1) for _ in range(N+1)] for _ in range(N+1)]
for i in range(N+1):
    for j in range(N+1):
        for k in range(50*N+1):
            if i == j == k == 0:
                dp[i][j][k] = 1
            elif i and k < x[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            elif i and j and k >= x[i-1]:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i-1]]
ans = 0
for j in range(1, N+1):
    ans += dp[N][j][a*j]
print(ans)

Submission status: Runtime Error

Solution code:
N, K, X, Y = map(int, input().split())


print(abs(X * K + (N - K) * Y))

Submission status: Runtime Error

Solution code:
N, K, X, Y = map(int, input().split())

print(X * K + (N - K) * Y)

Submission status: Runtime Error

Solution code:
n=int(input())
k=int(input())
x=int(input())
y=int(input())
print(int(x*k+y*(n-k)*(n>k))

Submission status: Runtime Error

Solution code:
N, K, X, K = [int(input()) for i in range(4)]
print(X*K+Y*(N-K if N-K > 0 else 0))

Submission status: Runtime Error

Solution code:
N, K, X, H = [int(input()) for i in range(4)]
print(X*K+Y*(N-K))

Submission status: Runtime Error

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

#dp[j][k][s] = (x0...xj からk枚選んでxiの合計をsにするような選び方の総数)
dp = [[[0 for s in range(a*n+1) ] for k in range(n+1) ] for j in range(n)]

for j in range(n):
    dp[j][0][0]=1
    if x[0]<= a*n:
        dp[j][1][x[0]] = 1

for j in range(n-1):
    for k in range(n+1):
        for s in range(a*n+1):
            if k>j+2:
                dp[j+1][k][s]=0
            elif s>=x[j+1] and k>= 1:
                dp[j+1][k][s]=dp[j][k][s] + dp[j][k-1][s-x[j+1]]
            else:
                dp[j+1][k][s]=dp[j][k][s]

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

print(1)

Submission status: Runtime Error

Solution code:
a=[N,K,X,Y]
for i in range(0,4):
    a=a.append(input())
if N>K:
    print(K*X+(N-K)*Y)
else:
    print(N*X)

Submission status: Runtime Error

Solution code:
a=[N,K,X,Y]
for i in range(0,4):
    a=append(input())
if N>K:
    print(K*X+(N-K)*Y)
else:
    print(N*X)

Submission status: Runtime Error

Solution code:
N,K,X,Y=map(int,input().split(/n))
if N>K:
    print(K*X+(N-K)*Y)
else:
    print(N*X)

Submission status: Runtime Error

Solution code:
N,K,X,Y=map(int,input().split(sep))
if N>K:
    print(K*X+(N-K)*Y)
else:
    print(N*X)

Submission status: Runtime Error

Solution code:
N,K,X,Y=map(int,input().split(sep))
if N>K:
    print((K*X)+((N-K)*Y))
else:
    print(N*X)

Submission status: Runtime Error

Solution code:
N,K,X,Y=map(int,input().split(sep))
if N>K:
    print((K*X)+((N-K)*Y))
else:
    print((N*X))

Submission status: Runtime Error

Solution code:
N,K,X,Y=map(int,input().split(sep))
if N>K:
    print((K*X)+((N-K)*Y))
else:
    print(int(N*X))

Submission status: Runtime Error

Solution code:
N,K,X,Y=map(int,input().split(sep))
if N>K:
    print(int((K*X)+((N-K)*Y)))
else:
    print(int(N*X))

Submission status: Runtime Error

Solution code:
N,K,X,Y=map(int,input().split(sep))
print(int((K*X)+((N-K)*Y)))

Submission status: Runtime Error

Solution code:
n, k, x, y = [int(iput()) for _ in range(4)]
print(k * x + (n-k) * y)

Submission status: Runtime Error

Solution code:
N=input()
K=input()
X=input()
Y=input()
S=K*X+(N-K)*Y
print(S)

Submission status: Runtime Error

Solution code:
n,k,x,y=[int(i) for i in input().split()]
print(min(n,k)*x+max(0,n-k)*y)

Submission status: Runtime Error

Solution code:
n,k,x,y=map(int,input().split())
x_day = min( [n,k] )
y_day = max( [0,n-k])
print( x*x_day + y*y_day )

Submission status: Runtime Error

Solution code:
n = input()
k = input()
x = input()
y = input()
sum = 0
sum += k * x
sum += (n-k) * y
print(sum)

Submission status: Runtime Error

Solution code:
n, a = map(int, input().split())
x = list(map(int, input().split()))
X = max(max(x), a)
dp = [[[0] * (n * X + 1) for i in range(n + 1)] for j in range(n + 1)]
dp[0][0][0] = 1
for i in range(1, n + 1):
    for j in range(n + 1):
        for s in range(n * X + 1):
            if s < x[i - 1]:
                dp[i][j][s] = dp[i - 1][j][s]
            elif j >= 1 and x[i - 1] <= s:
                dp[i][j][s] = dp[i - 1][j][s] + dp[i - 1][j - 1][s - x[i - 1]]

num = 0
for i in range(1, n + 1):
    num += dp[n][i][i * a]

print(num)

Submission status: Runtime Error

Solution code:
N, K, X, Y = map(int, input().split())
print(K*X + (N-K)*Y)

Submission status: Runtime Error

Solution code:
n = int(raw_input())
k = int(raw_input())
x = int(raw_input())
y = int(raw_input())
if n < = k:
  print(x*n)
else:
  print(x*k+y*(n-k))

Submission status: Runtime Error

Solution code:
n = input()
k= input()
X = input()
y = input()
if n<=k:
    total = n*x
else:
    total = k*x + (n-k) * y
print(total)

Submission status: Runtime Error

Solution code:
from sys import stderr
from functools import reduce
from operator import add
def f(): return [int(i) for i in input().split()]
def debug(*x): stderr.write(reduce(add, repr(x)).strip("()\',") + '\n')

n, a = f()
x = f()
s = sum(x)

dp = [[[0 for i in range(n + 1)] for j in range(s + 1)] for k in range(n + 1)]
for i in range(n + 1):
    dp[i][0][0] = 1

for i in range(1, n + 1):
    for j in range(1, s + 1):
        for k in range(1, n + 1):
            dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - x[i - 1]][k - 1]

ans = 0
k = 1
while a * k <= s and k <= n:
    ans += dp[n][a*k][k]
    k += 1
print(ans)

Submission status: Runtime Error

Solution code:
N,K,X,Y = map(int,input().split())
if N < K:
    print(X * N)
else:
    print(K * X + (N - K) * Y)

Submission status: Runtime Error

Solution code:
N,K,X,Y = map(int,input().split())
price = 0
for i in range(1,N+1):
    if i <= K:
        price += X
    else:
        price += Y
print(price)

Submission status: Runtime Error

Solution code:
n, k, x, y = map(int, input())
print(x*min(n, k)+y*max(0, n-k))

Submission status: Runtime Error

Solution code:
N = input()
K = input()
X = input()
Y = input()

if N > K:
    s = N - K
    r = (K * X) + (s * Y)
    print(r)
else:
    print(N*X)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# coding:utf-8
import os, sys
import math

N = input()
K = input()
X=input()
Y=input()
if N-K >= 0:
    print X*K + Y*(N-K)
else:
    pritn X*K

Submission status: Runtime Error

Solution code:
a = [int(input()) for i in range(4)]
sum = 0
for i in range(a[0]):
    if i + 1 <= K:
        sum += a[2]
    else:
        sum += a[3]
print(sum)

Submission status: Runtime Error

Solution code:
>>> N = 5
>>> K = 1000
>>> K = 2
>>> X = 1000
>>> Y = 1200
>>> print(K*X + Y*3)
5600
>>>

Submission status: Runtime Error

Solution code:
N, K, X, Y = [input() for i in range(4)]
if N <= K:
    print(N*X)
else:
    print((N-K)*Y + K*X)

Submission status: Runtime Error

Solution code:
n = int(input())
k = int(input())
x = int(input())
y = int(input())

return x * n if n < k
return x * k + y * (n - k)

Submission status: Runtime Error

Solution code:
n = input()
k = input()
x = input()
y = input()

return x * n if n < k
return x * k + y * (n - k)

Submission status: Runtime Error

Solution code:
def app(numlist, A ):
  counter = 0
  N = len(numlist)
  for i in range(1,N):
    counter += f(numlist, i, A*i)
  return int(counter)
 
def f(numlist, rest, sum):
  result = 0
  numset = set(numlist)
  if rest == 1:
    return numlist.count(sum)
 
  elif rest == 2:
    for big in numset:
      if (sum - big in numset) and (big >= sum - big):
        result += counter(numlist, big, sum-big)
    return result
  else:
    for i in numset:
      i_place = numlist.index(i)
      result += f(numlist[i_place+1:], rest-1, sum-i)
    return result
 
 
def counter(numlist, big, small):
  hist = mkhist(numlist)
  if big == small:
    N = hist[big]
    return N * (N - 1) / 2
  else: 
    big_N = hist[big]
    small_N = hist[small]
    return big_N * small_N
 
def mkhist(numlist):
  hist = dict()   
  for char in numlist:
    if not char in hist.keys():
      hist[char] = 1
    else:
      hist[char] += 1
  return hist
 
 
 
 
N, A = map(int, input().split(' '))
inputs = input()
 
inputnum = map(int, inputs.split(' '))
inputnum = sorted(list(inputnum))
 
print (app(inputnum, A))

Submission status: Runtime Error

Solution code:
 n = 4
 input_list = []
 for i in range(4):
     input_list.append(int(input()))

N = input_list[0]
K = input_list[1]
X = input_list[2]
Y = input_list[3]

if N > K :
    result = K * X + (N-K) * Y
else:
    result = K * X

print ( result )

Submission status: Runtime Error

Solution code:
N, A = map(int, raw_input().split())
a = sorted(map(lambda x:int(x)-A, raw_input().split()))
mem = {}

def rec(p, acm):
    if (p, acm) in mem:
        return mem[(p, acm)]
    if p >= N:
        return 0
    if a[p] > 0 and acm > 0:
        return 0
    mem[(p, acm)] = rec(p+1, acm+a[p]) + rec(p+1, acm)
    if acm+a[p] == 0:
        mem[(p, acm)] += 1
    return mem[(p, acm)]

print rec(0, 0)

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
    N,K,X,Y = map(int, raw_input().split())
    if(N <= K):
        print (N * X)
    else :
        print (K * X) + ((N-K) * Y)

Submission status: Runtime Error

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

N = int(raw_input())
K = int(raw_input())
X = long(raw_input())
Y = long(raw_inpuit())

sum = 0
if N >= K:
     sum = X * K + Y * (N - K)
else:
     sum = X * N

print sum

Submission status: Runtime Error

Solution code:
N = input()
K = input()
X = input ()
Y = input()
if N > K:
	for K:
		X += X
	for (N - K):
		X += Y
else:
	for N:
		X =+ X

Submission status: Runtime Error

Solution code:
N = input()
K = input()
X = input()
Y = input()

if N > K:
    res = K*X + (N-K)*Y 
else
    res = N*X

print(res)

Submission status: Runtime Error

Solution code:
import sys 

N = sys.readline()
K = sys.readline()
X = sys.readline()
Y = sys.readline()

#X* K + Y * (N-K)
# if N > K

#X * K
# if N < K

if N > K : 
        print X* K + Y *(N-K)
else:
        print X*K