AtCoder Beginner Contest 044 - Tak and Hotels (ABC Edit)

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-----
5
3
10000
9000

-----Sample Output-----
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.

Difficulty: EASY

Starter code:

Solutions:
(n, k, x, y) = [int(input()) for _ in 'nkxy']
print(min(n, k) * x + max(n - k, 0) * y)


n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n >= k:
	print(k * x + (n - k) * y)
else:
	print(n * x)


import sys

def I():
	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 main():
	n = I()
	k = I()
	x = I()
	y = I()
	if n <= k:
		print(n * x)
	else:
		print(k * x + (n - k) * y)

def __starting_point():
	main()
__starting_point()


(n, k, x, y) = [int(input()) for i in range(4)]
a = k * x + (n - k) * y if n - k > 0 else n * x
print(a)


N = int(input())
K = int(input())
X = int(input())
Y = int(input())
print(max(0, N - K) * Y + min(K, N) * X)


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


(n, k, x, y) = [int(input()) for i in range(4)]
print(x * min(n, k) + y * max(n - k, 0))


(n, k, x, y) = [int(input()) for _ in range(4)]
print(n * x - (x - y) * max(n - k, 0))


i = input
(N, K, X, Y) = map(int, [i(), i(), i(), i()])
print(sum([X if i < K else Y for i in range(N)]))


from sys import stdin
input = stdin.readline
(n, k, x, y) = list(map(int, stdin.read().split()))
print(min(k, n) * x + max(0, n - k) * y)


(n, k, x, y) = [int(input()) for i in range(4)]
if k > n:
	k = n
print(k * x + (n - k) * y)


(n, k, x, y) = [int(input()) for _ in [0] * 4]
print(n * x) if n < k else print(y * (n - k) + x * k)


(N, K, X, Y) = [int(input()) for _ in range(4)]
print(min(N, K) * X + max(0, N - K) * Y)


(N, K, X, Y) = map(int, open(0).read().split())
if K < N:
	print(K * X + (N - K) * Y)
else:
	print(N * X)


n = int(input())
k = int(input())
x = int(input())
y = int(input())
print(n * x - (x - y) * max(n - k, 0))


total = int(input())
disc = int(input())
priceX = int(input())
priceY = int(input())
ans = ()
if total <= disc:
	ans = total * priceX
else:
	ans = disc * priceX + (total - disc) * priceY
print(ans)


(n, k, x, y) = map(int, open(0))
print(min(k, n) * x + max(0, n - k) * y)


n = int(input())
k = int(input())
x = int(input())
y = int(input())
ans = 0
if n >= k:
	ans += x * k
	n -= k
	ans += y * n
else:
	ans += x * n
print(ans)


n = int(input())
k = int(input())
x = int(input())
y = int(input())
print((k * x + (n - k) * y, n * x)[k >= n])


n = int(input())
k = int(input())
print(min(k, n) * int(input()) + max(0, n - k) * int(input()))


n = int(input())
k = int(input())
x = int(input())
y = int(input())
fees = 0
if k > n or n == k:
	for i in range(0, n):
		fees += x
elif k < n:
	diff = n - k
	for j in range(0, k):
		fees += x
	for k in range(0, diff):
		fees += y
print(fees)


d = [int(input()) for i in range(4)]
s = d[0] - d[1]
print(d[1] * d[2] + s * (d[3] if s > 0 else d[2]))


(a, b, c, d) = [int(input()) for i in range(4)]
if a < b:
	print(a * c)
else:
	print(b * c + (a - b) * d)


N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N <= K:
	print(N * X)
else:
	print(K * X + (N - K) * Y)


a = [int(input()) for i in [0] * 4]
print(min(a[:2]) * a[2] + max(0, a[0] - a[1]) * a[3])


a = int(input())
b = int(input())
c = int(input())
d = int(input())
print(min(a, b) * c + max(a - b, 0) * d)


def iroha():
	(n, k, price, special) = [int(input()) for i in range(4)]
	result = 0
	for i in range(n):
		if i < k:
			result += price
		else:
			result += special
	print(result)

def __starting_point():
	iroha()
__starting_point()


(N, K, X, Y) = [int(input()) for i in range(4)]
print(N * X - (X - Y) * max(0, N - K))


(N, K, X, Y) = [int(input()) for _ in ' ' * 4]
print(X * N + (X - Y) * (K - N) * (K < N))


N = int(input())
K = int(input())
X = int(input())
Y = int(input())
price = 0
if N <= K:
	for i in range(N):
		price += X
	print(price)
else:
	for i in range(K):
		price += X
	for i in range(N - K):
		price += Y
	print(price)


n = int(input())
k = int(input())
a = int(input())
b = int(input())
print(min(n, k) * a + max(0, n - k) * b)


import sys
(N, K, X, Y) = map(int, sys.stdin.readlines())
print(K * X + (N - K) * Y if N > K else N * X)


n = int(input())
k = int(input())
x = int(input())
y = int(input())
ans = 0
for i in range(n):
	if i + 1 <= k:
		ans += x
	if i + 1 > k:
		ans += y
print(ans)


N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N <= K:
	print(N * X)
elif N >= K:
	k_stay = K * X
	k_plus_stay = (N - K) * Y
	print(k_plus_stay + k_stay)


(N, K, X, Y) = eval('int(input()),' * 4)
print(K * X + (N - K) * Y if N - K > 0 else N * X)


def main():
	n = int(input())
	k = int(input())
	x = int(input())
	y = int(input())
	print(n * x - (x - y) * max(n - k, 0))

def __starting_point():
	main()
__starting_point()


L = [int(input()) for _ in range(4)]
print(L[2] * min(L[0], L[1]) + L[3] * max(0, L[0] - L[1]))


(a, b, c, d) = (int(input()) for i in range(4))
print(a * c - (c - d) * max(a - b, 0))


A = [int(input()) for i in range(4)]
print(A[2] * min(A[0], A[1]) + A[3] * max(0, A[0] - A[1]))


n = int(input())
k = int(input())
x = int(input())
y = int(input())
ans = min(n, k) * x
n -= min(n, k)
ans += n * y
print(ans)


import sys
(n, k, x, y) = map(int, sys.stdin)
print(x * min(n, k) + (n - k) * (n > k) * y)


N = int(input())
K = int(input())
X = int(input())
Y = int(input())
ans = 0
for i in range(1, N + 1):
	if i <= K:
		ans += X
	else:
		ans += Y
print(ans)


def solve():
	n = int(input())
	k = int(input())
	x = int(input())
	y = int(input())
	print(x * min(n, k) + y * max(n - k, 0))

def __starting_point():
	solve()
__starting_point()


n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n > k:
	print(k * x + (n - k) * y)
elif n <= k:
	print(n * x)


n = int(input())
k = int(input())
x = int(input())
y = int(input())
s = 0
for i in range(1, n + 1, 1):
	if i <= k:
		s += x
	else:
		s += y
print(s)


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


(N, K, x, y) = [int(input()) for i in range(4)]
if K < N:
	print((N - K) * y + K * x)
else:
	print(N * x)


(N, K, X, Y) = [int(input()) for _ in range(4)]
x = min(N, K)
y = N - x
print(X * x + Y * y)


(n, k, x, y) = [int(input()) for i in range(4)]
z = min(n, k)
print(z * x + (n - z) * y)


from sys import stdin
input = stdin.readline
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N <= K:
	cost = N * X
else:
	cost = K * X + (N - K) * Y
print(cost)


class Combination:

	def __init__(self, n, mod):
		self.n = n
		self.mod = mod
		self.fac = [1 for i in range(self.n + 1)]
		self.finv = [1 for i in range(self.n + 1)]
		for i in range(2, self.n + 1):
			self.fac[i] = self.fac[i - 1] * i % self.mod
			self.finv[i] = self.finv[i - 1] * pow(i, -1, self.mod) % self.mod

	def comb(self, n, m):
		return self.fac[n] * (self.finv[n - m] * self.finv[m] % self.mod) % self.mod

def iparse():
	return list(map(int, input().split()))

def __starting_point():
	n = int(input())
	k = int(input())
	x = int(input())
	y = int(input())
	print(min(k, n) * x + max(0, n - k) * y)
__starting_point()


(n, k, x, y) = [int(input()) for _ in range(4)]
if k <= n:
	sum = x * k + y * (n - k)
else:
	sum = x * n
print(sum)


(a, b, c, d) = eval('int(input()),' * 4)
print(c * min(a, b) + d * max(a - b, 0))


N = int(input())
K = int(input())
X = int(input())
Y = int(input())
ans = 0
if N > K:
	for i in range(0, K):
		ans += X
	for i in range(K, N):
		ans += Y
elif N <= K:
	for i in range(0, N):
		ans += X
print(ans)


val = [int(input()) for i in range(4)]
if val[0] > val[1]:
	print(val[1] * val[2] + (val[0] - val[1]) * val[3])
else:
	print(val[0] * val[2])


import math
from datetime import date

def main():
	n = int(input())
	k = int(input())
	x = int(input())
	y = int(input())
	ans = max(0, n - k) * y + min(n, k) * x
	print(ans)
main()


(N, K, X, Y) = map(int, open(0))
print(N * X) if N <= K else print(K * X + (N - K) * Y)


(n, k, x, y) = eval('int(input()),' * 4)
print(n * x - (x - y) * max(n - k, 0))


(n, k, x, y) = map(int, open(0))
print(n * x if n <= k else x * k + y * (n - k))


(N, K, X, Y) = map(int, open(0).read().split())
print(min(N, K) * X + max(0, N - K) * Y)


(N, K, X, Y) = map(int, open(0))
print([N * X, K * X + (N - K) * Y][K < N])


n = int(input())
k = int(input())
x = int(input())
y = int(input())
ans = min(n, k) * x + max(n - k, 0) * y
print(ans)


(n, k, x, y) = [int(input()) for i in [0] * 4]
ans = 0
ans += min(k, n) * x
n -= min(k, n)
print(ans + y * n)


(N, K, X, Y) = [int(input()) for _ in range(4)]
m = min(N, K)
print(X * m + Y * (N - m))


N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if (1 <= N & N <= 10000) & (1 <= K & K <= 10000) & (1 <= X & X <= 10000) & (1 <= Y & Y <= 10000):
	if X > Y:
		price = 0
		if N < K:
			for i in range(1, N + 1):
				price += X
		if N >= K:
			for i in range(1, K + 1):
				price += X
			for j in range(K + 1, N + 1):
				price += Y
		print(price)


total = int(input())
initial = int(input())
if initial > total:
	initial = total
a = int(input())
b = int(input())
count = 0
for i in range(initial):
	count += a
for c in range(total - initial):
	count += b
print(count)


N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N <= K:
	account = N * X
else:
	account = K * X + max(N - K, 0) * Y
print(account)


(n, k, x, y) = map(int, open(0))
print([n * x, k * x + (n - k) * y][n > k])


(N, K, X, Y) = [int(input()) for _ in range(4)]
result = min(N, K)
N -= result
result *= X
if N >= 0:
	result += N * Y
print(result)


import sys
import math
sys.setrecursionlimit(10 ** 8)
ini = lambda : int(sys.stdin.readline())
inm = lambda : map(int, sys.stdin.readline().split())
inl = lambda : list(inm())
ins = lambda : sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print('\x1b[33m', *a, '\x1b[0m', **dict(file=sys.stderr, **kw))
N = ini()
K = ini()
X = ini()
Y = ini()
if N > K:
	print(K * X + (N - K) * Y)
else:
	print(N * X)


(n, k, x, y) = map(int, open(0).read().split())
print(min(n, k) * x + max(0, n - k) * y)


def main():
	n = int(input())
	k = int(input())
	x = int(input())
	y = int(input())
	if n <= k:
		ans = x * n
	else:
		ans = x * k + y * (n - k)
	print(ans)

def __starting_point():
	main()
__starting_point()


(n, k) = [int(input()) for i in range(2)]
print(min(n, k) * int(input()) + max(n - k, 0) * int(input()))


(n, k, x, y) = map(int, open(0).read().split())
print(x * n if n <= k else x * k + y * (n - k))


import sys
from heapq import heappush, heappop, heapify
import math
from math import gcd
import itertools as it
from collections import deque
input = sys.stdin.readline

def inp():
	return int(input())

def inpl():
	return list(map(int, input().split()))
INF = 1001001001

def main():
	n = inp()
	k = inp()
	x = inp()
	y = inp()
	if n > k:
		print(x * k + y * (n - k))
	else:
		print(x * n)
main()


(N, K, X, Y) = [int(input()) for _ in range(4)]
print(N * X if N - K < 0 else K * X + (N - K) * Y)


n = int(input())
k = int(input())
x = int(input())
y = int(input())
first = min(n, k)
re = first * x
re += max(n - first, 0) * y
print(re)


l = [int(input()) for i in range(4)]
print(l[0] * l[2] - max(l[0] - l[1], 0) * (l[2] - l[3]))


n = int(input())
k = int(input())
x = int(input())
y = int(input())
cost = 0
if n > k:
	for i in range(k):
		cost += x
	for j in range(k, n):
		cost += y
	print(cost)
elif n <= k:
	for i in range(n):
		cost += x
	print(cost)


a = int(input())
b = min(a, int(input()))
print(b * int(input()) + int(input()) * (a - b))


(n, k, x, y) = [int(input()) for _ in '1' * 4]
print(x * n - (x - y) * [0, n - k][n - k > 0])


(N, K, X, Y) = map(int, open(0))
print(min(N, K) * X + max(0, N - K) * Y)