Problem:


Score : 300 points

Problem Statement

You've come to your favorite store Infinitesco to buy some ice tea.

The store sells ice tea in bottles of different volumes at different costs.
Specifically, a 0.25-liter bottle costs Q yen, a 0.5-liter bottle costs H yen, a 1-liter bottle costs S yen, and a 2-liter bottle costs D yen.
The store has an infinite supply of bottles of each type.

You want to buy exactly N liters of ice tea. How many yen do you have to spend?

Constraints

1 \leq Q, H, S, D \leq 10^8

1 \leq N \leq 10^9

All input values are integers.

Input

Input is given from Standard Input in the following format:

Q H S D
N

Output

Print the smallest number of yen you have to spend to buy exactly N liters of ice tea.

Sample Input 1

20 30 70 90
3

Sample Output 1

150

Buy one 2-liter bottle and two 0.5-liter bottles. You'll get 3 liters for 90 + 30 + 30 = 150 yen.

Sample Input 2

10000 1000 100 10
1

Sample Output 2

100

Even though a 2-liter bottle costs just 10 yen, you need only 1 liter.
Thus, you have to buy a 1-liter bottle for 100 yen.

Sample Input 3

10 100 1000 10000
1

Sample Output 3

40

Now it's better to buy four 0.25-liter bottles for 10 + 10 + 10 + 10 = 40 yen.

Sample Input 4

12345678 87654321 12345678 87654321
123456789

Sample Output 4

1524157763907942



Sample input:
20 30 70 90
3


Sample output:
150

Submission status: Accepted

Solution code:
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

Q,H,S,D = imn()
N = iin()

min1L = min(Q*4, H*2, S)
min2L = min(min1L*2, D)

ans = N//2*min2L
if N % 2 == 1: ans += min1L
print(ans)

Submission status: Accepted

Solution code:
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

Q,H,S,D = imn()
N = iin()

min1L = min(Q*4, H*2, S)
min2L = min(min1L*2, D)

if N % 2 == 1:
    print(N//2*min2L + min1L)
else:
    print(N//2*min2L)

Submission status: Accepted

Solution code:
Q, H, S, D = map(int, input().split())
N = int(input())
L = [S,H*2,Q*4]
if min(L)*2 < D:
    print(min(L)*N)
else:
    if N % 2 == 0:
        print(D*(N//2))
    else:
        print(D*(N//2)+min(L))

Submission status: Accepted

Solution code:
Q, H, S, D = map(int, input().split())
N = int(input())
Q *= 4
H *= 2
ans = 0
if N & 1:
    ans += min(Q, H, S)
ans += min(2*Q, 2*H, 2*S, D)*(N//2)
print(ans)

Submission status: Accepted

Solution code:
Q,H,S,D = map(int,input().split())
N = int(input())
h = min(2*Q,H)
s = min(2*h,S)
d = min(2*s,D)
print((N//2)*d + (N%2)*s)

Submission status: Accepted

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())
print((n // 2) * min(8 * q, 4 * h, 2 * s, d) + (n % 2) * min(4 * q, 2 * h, s))

Submission status: Accepted

Solution code:
Q, H, S,D = map(int, input().split())
N = int(input())
# Dから順番に使おうとする
# Nを4倍しておこう
N *= 4
cnt = 0
# D > 2*Sなら使わない
if D <= 2 * S and D <= 4*H and D <= 8*Q:
    cnt += N // 8 *  (D)
    N %= 8

# 次、Sを使うかどうか
if S <= 2 * H and S <= 4*Q:
    cnt += N // 4 * (S)
    N %= 4

# 次、Hを使うかどうか
if H <= 2 * Q :
    cnt += N // 2 * (H)
    N %= 2

# 最後
cnt += N * (Q)

print(cnt)

Submission status: Accepted

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

l = [min(p[0] * 4, p[1] * 2, p[0] * 2 + p[1], p[2]), p[3]]
ppl = [l[0], l[1] / 2]

if (ppl[0] <= ppl[1]):
    print(n * l[0])
else:
    print((n//2)*l[1] + (n % 2) * l[0])

Submission status: Accepted

Solution code:
q,h,s,d = map(int, input().split())
n = int(input()) * 100
#値の更新をしていく
h = min(h,q*2)
s = min(s,h*2)
d = min(d,s*2)
ans = 0
count = 0
count = n//200
ans += count * d
n -= count*200

count = n//100
ans += count * s
n -= count*100

count = n//50
ans += count * h
n -= count*50

count = n//25
ans += count * q
n -= count*25
print(ans)

Submission status: Accepted

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


def solve(Q: int, H: int, S: int, D: int, N: int):
    x = min(4*Q,2*H,S)
    y = D

    if x<=y/2:
        print(N*x)
    else:
        if N&1:
            print(N//2*y+x)
        else:
            print(N//2*y)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    Q = int(next(tokens))  # type: int
    H = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(Q, H, S, D, N)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())

# 2L min cost
cost2 = min(q*8, h*4, s*2, d)
# 1L min cost
cost1 = min(q*4, h*2, s)

ans = (n // 2) * cost2
if n % 2 == 1:
  ans += cost1
print(ans)

Submission status: Accepted

Solution code:
import math

q, h, s, d = map(int, input().split())
n = int(input())*100

qq = [q, q, 25]
hh = [h/2, h, 50]
ss = [s/4, s, 100]
dd = [d/8, d, 200]
qhsd = [qq, hh, ss, dd]
qhsd.sort()

ans = 0
for i in range(4):
    num = n//qhsd[i][2]
    n -= num*qhsd[i][2]
    ans += num*qhsd[i][1]
print(ans)

Submission status: Accepted

Solution code:
a,b,c,d=map(int,input().split())
a=min(4*a,2*b,c)
N=int(input())
if 2*a<=d:
  print(N*a)
else:
  if N%2==0:
    print(N//2*d)
  else:
    print(N//2*d+a)

Submission status: Accepted

Solution code:
def main():
    q, h, s, d = map(int, input().split())
    target = int(input())
    h = min(2 * q, h)
    s = min(2 * h, s)
    d = min(2 * s, d)
    answer = target // 2 * d + (target % 2) * s
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
Q,H,S,D = map(int,input().split())
N=int(input())
A=[]

A.append(4*Q)
A.append(2*H)
A.append(S)
A.append(D/2)

if min(A)==A[0]:
  print(N*A[0])
elif min(A)==A[1]:
  print(N*A[1])
elif min(A)==A[2]:
  print(N*A[2])
else:
  a = N//2
  p = a*D
  if a*2!=N:
    if A[0]<=A[1] and A[0]<=A[2]:
      p += A[0]
    elif A[1]<=A[2] and A[1]<=A[0]:
      p += A[1]
    else:
      p += A[2]
  print(p)

Submission status: Accepted

Solution code:
Q, H, S, D = map(int, input().split())
N = int(input())

ans = (N // 2) * min(Q * 8, H * 4, S * 2, D)
if N % 2 == 0:
    print(ans)
else:
    ans += min(Q * 4, H * 2, S)
    print(ans)

Submission status: Accepted

Solution code:
Q, H, S, D = map(int, input().split())
N = int(input())
A = [Q * 8, H * 4, S * 2, D]
B = [Q * 4, H * 2, S]
Ans = 0

cnt = N // 2
N = N % 2
Ans = Ans + min(A) * cnt
Ans = Ans + min(B) * N
print(Ans)

Submission status: Accepted

Solution code:
q,h,s,d=map(int,input().split())
n=int(input())
h=min(h,q*2)
s=min(s,h*2)
d=min(d,s*2)
print((n//2)*d + (n%2)*s)

Submission status: Accepted

Solution code:
q,h,s,d = map(int, input().split())
n = int(input())

ans = 0

print(min(q * 8, h * 4, s * 2, d) * (n // 2)+min(q * 4, h * 2, s) *(n%2==1))

Submission status: Accepted

Solution code:
Q,H,S,D = map(int, input().split())
N = int(input())

H = min(H, Q * 2)
S = min(S, H * 2)
D = min(D, S * 2)

#print(S, D)

ans = (N // 2) * D + (N - (N // 2) * 2) * S
print(ans)

Submission status: Accepted

Solution code:
Q, H, S, D = map(int, input().split())
N = int(input())

rate = {"Q": 4 * Q, "H": 2 * H, "S": S, "D": 1 / 2 * D}
price = 0
score_sorted = sorted(rate.items(), key=lambda x: x[1])
for x in score_sorted:
    if x[0] == "D" and N >= 2:
        div, mod = divmod(N, 2)
        N = mod
        price = D * div
    elif x[0] == "S":
        price += N * S
        break
    elif x[0] == "H":
        price += N * H * 2
        break
    elif x[0] == "Q":
        price += N * Q * 4
        break
    if N == 0:
        break
print(price)

Submission status: Accepted

Solution code:
Q,H,S,D=map(int,input().split())
N=int(input())
ans=min(4*N*Q,2*N*H,N*S,N//2*D)
if ans==N//2*D and N%2==1:
    ans+=min(4*Q,2*H,S)
    ans=min(ans,4*N*Q,2*N*H,N*S)
print(ans)

Submission status: Accepted

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())
h = min(q*2, h)
s = min(h*2, s)
if 2*s <= d:
  print(s*n)
else:
  if n%2==0:
    print(d*(n//2))
  else:
    print(d*(n//2)+s)

Submission status: Accepted

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())

l2 = [q*8, h*4, s*2, d]
l1 = [q*4, h*2, s]

ans = (n//2) * min(l2) + (n%2) * min(l1)
print(ans)

Submission status: Accepted

Solution code:
Q,H,S,D = map(int,input().split())
N = int(input())

prc2 = min(Q*8,H*4,S*2,D)
prc1 = min(Q*4,H*2,S)
print((N//2)*prc2+(N%2)*prc1)

Submission status: Accepted

Solution code:
ans_list = list(map(int, input().split()))
N = int(input())
ans_list[1] = min(ans_list[0]*2, ans_list[1])
ans_list[2] = min(ans_list[1]*2, ans_list[2])
if ans_list[2]*2<=ans_list[3]:
    print(N*ans_list[2])
else:
    print(ans_list[3]*(N//2)) if N%2==0 else print(ans_list[3]*(N//2)+ans_list[2])

Submission status: Accepted

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())
s_ = min(q*4, h*2, s)
d_ = min(q*8, h*4, s*2, d)
print(min(s_*n, d_*(n//2)+(n%2)*s_))

Submission status: Accepted

Solution code:
q,h,s,d=list(map(int, input().split()))
x=int(input())

q=q*4
h=h*2

if q<s:
	s=q
if h<s:
	s=h

if s*2<=d:
	print(x*s)
else:
	if x % 2 == 0:
		print((x*d)//2)
	else:
		print(((x//2)*d)+s)

Submission status: Accepted

Solution code:
q,h,s,d = map(int,input().split())
n = int(input())
h = min(q*2,h)
s = min(h*2,s)

if 2*s <= d:
    print(n*s)
else:
    print(n//2*d+(n%2)*s)

Submission status: Accepted

Solution code:
def main():
    q, h, s, d = map(int, input().split())
    n = int(input())
    x = min(4*q, 2*h, s)
    y = min(2*x, d)
    ans = n//2*y
    if n%2 == 1:
        ans += x
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
q,h,s,d = map(int,input().split())
n=int(input())

res = 0
ll=min(q*8,h*4,s*2,d)
l=min(q*4,h*2,s)
if n%2== 0:
    print(ll*(n//2))
else:
    print(ll*(n//2)+l)

Submission status: Accepted

Solution code:
q, h, s, d=map(int, input().split())
n=int(input())

x1=min(4*q, 2*h, s)
x2=min(2*x1, d)
print((n//2)*x2+(n%2)*x1)

Submission status: Accepted

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

q, h, s, d = map(int, input().split())
n = int(input())
ans = 0

if n >= 2:
  ans += min(8 * q, 4 * h, 2 * s, d) * math.floor(n / 2)

if n % 2 == 1:
  ans += min(4 * q, 2 * h, s)
  
print(ans)

Submission status: Accepted

Solution code:
Q, H, S, D = map(int, input().split())
N = int(input())

A = min(Q*4, H*2, S)
if N % 2 == 0:
    print(min(A*N, D*N//2))
else:
    if N == 1:
        print(A)
    else:
        print(min(A*N, D*(N//2)+A))

Submission status: Accepted

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())
h = min(q*2, h)
s = min(h*2, s)
d = min(s*2, d)
if n % 2 == 0:
  print(min(s*n, d*(n//2)))
else:
  print(min(s*n, d*(n//2)+s))

Submission status: Accepted

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

# 1リットル買う
min_for_one = min(a*4, b*2, c)

min_for_two = min(a*8, b*4, c*2, d)

if n % 2 == 1:
    print((n //2)* min_for_two + min_for_one)
else:
    print(n // 2 * min_for_two)

Submission status: Accepted

Solution code:
q,h,s,d=map(int,input().split())
n=int(input())
qhs=min(q*4,h*2,s)
if qhs*2<=d:
    print(qhs*n)
else:
    print(d*(n//2)+qhs*(n%2))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
q,h,s,d = map(int,input().split())
N=int(input())

x=min(q*8,h*4,s*2,d)#2Lあたりの値段 
y=min(q*4,h*2,s)
if N % 2 == 0:
    ans = x * (N//2)
else:
    ans = x * (N // 2)
    ans += y

print(ans)

Submission status: Accepted

Solution code:
Q,H,S,D=map(int,input().split())
N=int(input())
usage=[]
slist=[4*Q,2*H,S]
slist.sort()
s=slist[0]  #これが1Lの値段に
dlist=[8*Q,4*H,2*s,D]
dlist.sort()
d=dlist[0]  #これが2Lの値段に

if N%2==0:
    print(d*(N//2))
else:
    print(d*(N//2)+s)

Submission status: Accepted

Solution code:
Q, H, S, D = list(map(int, input().split()))
N = int(input())

t = min(4*Q, 2*H, S)
if D < 2 * t:
    if N % 2 == 0:
        ans = (N // 2) * D
    else:
        ans = (N // 2) * D + t
else:
    ans = N * t

print(ans)

Submission status: Accepted

Solution code:
Q, H, S, D = list(map(int, input().split()))
N = int(input())

ans1 = 4 * Q * N
ans2 = 2 * H * N
ans3 = S * N

if N < 2:
    ans4 = float('INF')
elif N % 2 == 0:
    ans4 = (N // 2) * D
else:
    t = (N // 2) * D
    ans4 = t + min(4 * Q, 2 * H, 1 * S)

# print(ans1, ans2, ans3, ans4)
ans = min(ans1, ans2, ans3, ans4)
print(ans)

Submission status: Accepted

Solution code:
q, h, s, d = map(int,input().split())
n = int(input())
v1 = min(q*4, h*2, s* 1)
v2 = min(v1 * 2, d)
print(n // 2 * v2 + n%2 * v1)
#print(v1, v2)

Submission status: Accepted

Solution code:
Q,H,S,D,N=map(int, open(0).read().split())
S=min(S,H*2,Q*4)
print(min(N//2*D+N%2*S, N*S))

Submission status: Accepted

Solution code:
q,h,s,d=map(int,input().split())
n=int(input())
x=min(s,2*h,4*q)
div,mod=divmod(n,2)
print(min(d*div+x*mod, x*n))

Submission status: Accepted

Solution code:
Q, H, S, D = map(int, input().split())
N = int(input())
m1 = min(Q*4, H*2, S)

if N%2:
    print(N//2*D+m1 if D < 2*m1 else N*m1)
else:
    print(N*min(Q*8, H*4, S*2, D)//2)

Submission status: Accepted

Solution code:
Q, H, S, D = map(int, input().split())
N = int(input())

if N%2:
    if D < 2*min(Q*4, H*2, S):
        # 2L サイズの容量あたり単価が一番安いときは、N//2本買う
        # 残りは1Lになるので、0.25L,0.5L,1Lのなかから最も容量あたり単価が安いものを買う
        print(N//2*D+min(Q*4, H*2, S))
    else:
        # 0.25L,0.5L,1Lのなかから最も容量あたり単価が安いものを買う
        print(N*min(Q*4, H*2, S))
else:
    #0.25L,0.5L,1L,2Lのなかから最も容量あたり単価が安いものを買う
    print(N*min(Q*8, H*4, S*2, D)//2)

Submission status: Accepted

Solution code:
Q, H, S, D = map(int, input().split())
N = int(input())

if N%2:
    if D < 2*min(Q*4, H*2, S):
        print(N//2*D+min(Q*4, H*2, S))
    else:
        print(N*min(Q*4, H*2, S))
else:
    print(N*min(Q*8, H*4, S*2, D)//2)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
q, h, s, d = map(int,input().split())
n = int(input())

tmp = [4 * q, 2 * h, s, d / 2] #1Lあたりの値段
tmp.sort()
if tmp[0] == d / 2:
    if n % 2 == 0:
        ans = d * (n // 2)
    elif tmp[1] == s:
        ans = d * (n // 2) + s
    elif tmp[1] == 2 * h:
        ans = d * (n // 2) + 2 * h
    elif tmp[1] == 4 * q:
        ans = d * (n // 2) + 4 * q
elif tmp[0] == s:
    ans = s * n
elif tmp[0] == 2 * h:
    ans = h * n * 2
elif tmp[0] == 4 * q:
    ans = q * n * 4
print(ans)

Submission status: Accepted

Solution code:
from itertools import permutations
Q, H, S, D = map(int, input().split())
N = int(input())*4

ans = 0
s = [(Q, 1), (H, 2), (S, 4), (D, 8)]

ans = float("inf")
for x in permutations(s):
    tmp = 0
    n = N
    for a, b in x:
        tmp += (n // b)*a
        n %= b
    ans = min(ans, tmp)
print(ans)

Submission status: Accepted

Solution code:
def main():
    Q,H,S,D = map(int,input().split())
    N = int(input())
    mincos = min(4*Q,2*H,S)
    t1 = N*mincos
    t2 = (N//2)*D + (N%2)*mincos
    print(min(t1,t2))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
q,h,s,d=map(int,input().split())
n=int(input())
ans=int(0)
q*=4
h*=2
if n%2==1:
    ans+=min([q,h,s])
    n-=1

n=int(n/2)
ans+=n*min([2*q,2*h,2*s,d])
print(int(ans))

Submission status: Accepted

Solution code:
q,h,s,d=map(int,input().split())
n=int(input())
ans=int(0)
q*=4
h*=2
if n%2==1:
    ans+=min([q,h,s])
    n-=1

n//=2
ans+=n*min([2*q,2*h,2*s,d])
print(int(ans))

Submission status: Accepted

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())
liter = min(4 * q, 2 * h, s)
ans = min(liter * n, n // 2 * d + n % 2 * liter)
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

q,h,s,d=map(int,input().split())
n=int(input())
k=min(4*q,h*2,s)
if n % 2 == 1:
  ans += k
  n-=1
ans += n//2*min(2*k,d)
print(ans)

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    q, h, s, d = map(int, input().split())
    n = int(input())

    # まず1リットルあたりの単価を求める
    value = list()
    value.append(q*4)
    value.append(h*2)
    value.append(s)
    value.append(d/2)

    ans = 0
    if min(value) == value[3]:
        if n % 2 == 1:
            ans += n // 2 * d
            ans += min(value[0:3])
        else:
            ans += n // 2 * d
    else:
        ans += min(value) * n

    print(ans)

Submission status: Accepted

Solution code:
Q,H,S,D=map(int,input().split())
N=int(input())
ans=0
#each 2L
ans+=(N//2)*min([8*Q,4*H,2*S,D])
#1L
ans+=(N%2)*min([4*Q,2*H,S])
print(ans)

Submission status: Accepted

Solution code:
Q, H, S, D = map(int, input().split())
N = int(input())

two = min(D, S * 2, H * 4, Q * 8)
one = min(S, H * 2, Q * 4)

d, m = divmod(N, 2)
ans = d * two + m * one
print(ans)

Submission status: Accepted

Solution code:
Q, H, S, D = map(int,input().split())
N = int(input())
print(min(D,2*S,4*H,8*Q)*(N//2)+min(S,2*H,4*Q)*(N%2))

Submission status: Accepted

Solution code:
def main():
    Q, H, S, D = (int(i) for i in input().split())
    N = int(input())
    one = min(4*Q, 2*H, S)
    two = min(2*one, D)
    ans = 0
    if N & 1:
        ans += one
        N -= 1
    ans += two * (N // 2)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())
q *= 4
h *= 2
ans = min(min(q, h, s) * n, n // 2 * d + n % 2 * min(q, h, s))
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
Q, H, S, D = map(int, input().split())
N = int(input()) * 4
res = 0

res += (N // 8) * min(Q * 8, H * 4, S * 2, D)
N %= 8
res += (N // 4) * min(Q * 4, H * 2, S)
N %= 4
res += (N // 2) * min(Q * 2, H * 1)
N %= 2
res += N * Q
print(res)

Submission status: Accepted

Solution code:
q,h,s,d=map(int,input().split())
n=int(input())
q*=4
h*=2
s=min(q,h,s)
print(n//2*min(s*2,d)+n%2*s)

Submission status: Accepted

Solution code:
Q,H,S,D = map(int, input().split())
N = int(input())

ans = 0
if N >= 2:
    ans += N//2 * min(Q*8, H*4, S*2, D)
    N %= 2
if N == 1:
    ans += min(Q*4, H*2, S)
print(ans)

Submission status: Accepted

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())

ll = min(q*8, h*4, s*2, d)

res = 0
res += (n//2)*ll
n %= 2



res += min(q*4, h*2, s)*n


print(res)

Submission status: Accepted

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())

u = min(s, 4*q, 2*h)

ans = min(u*n, d*(n//2) + u*(n%2))
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
q,h,c,d=mii()
n=ii()


ll05 = min(2*q,h)
ll1 = min(ll05*2,c)
ll2 = min(ll1*2,d)
ans=10**100
if n%2==1:
    ans = (n//2)*ll2 + ll1
else:
    ans = (n//2)*ll2

print(ans)

Submission status: Accepted

Solution code:
Q, H, S, D = map(int, input().split())
N = int(input())

smin = min(4 * Q, 2 * H, S)
if D < 2 * smin:
    print((N // 2) * D + (N % 2) * smin)
else:
    print(N * smin)

Submission status: Accepted

Solution code:
def main():
    Q, H, S, D = map(int, input().split())
    N = int(input())

    N *= 4

    cost = [Q, H, S, D]
    # cost[pow] = 最小費用
    # Q:1=2**0
    # H:2=2**1
    # S:4=2**2
    # D:8=2**3

    for pow_i in range(3, 0, -1):
        cost[pow_i] = min(
            cost[pow_j] * (1 << (pow_i - pow_j))
            for pow_j in range(pow_i, -1, -1))

    ret = 0
    for pow in range(3, -1, -1):
        coef, N = divmod(N, 1 << pow)
        ret += coef * cost[pow]
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
q,h,s,d = map(int, input().split())
n = int(input())
q_cp=q*4
h_cp=h*2
s_cp=s
d_cp=d/2

vals = [[q_cp,0.25],[h_cp,0.5],[s_cp,1],[d_cp,2]]
vals.sort()

if vals[0][1] <= 1:
        print(n * vals[0][0])
else:
        ans=d*(n//2)
        if n%2==0:
                print(ans)
        else:
                ans+=vals[1][0]
                print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    Q, H, S, D = Scanner.map_int()
    N = Scanner.int()
    ans = 0
    H = min(Q * 2, H)
    S = min(H * 2, S)
    if S * 2 <= D:
        ans = S * N
    else:
        ans += D * (N // 2)
        ans += (N % 2) * S
    print(ans)
    return


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
Q,H,S,D = map(int,input().split())
H = min(H,2*Q)
S = min(S,2*H)
D = min(D,2*S)
N = int(input())
answer = 0
if N&1:
    answer += S
answer += (N//2)*D
print(answer)

Submission status: Accepted

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

bl = al[:]
bl[0] = bl[0] * 4
bl[1] = bl[1] * 2
bl[2] = bl[2] * 1
bl[3] = bl[3] / 2

idx = bl.index(min(bl))
idx2 = bl[:3].index(min(bl[:3]))
if idx == 3:
    print(n//2*al[idx] + (n%2) * bl[idx2])
else:
    print(bl[idx]*n)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
Q,H,S,D=map(int,input().split())
N=int(input())

n=N//2*2
ans=min(Q*4*n,H*2*n,S*n,D*n//2)

if N%2==1:
    ans+=min(Q*4,H*2,S)
    
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
Q,H,S,D=map(int,input().split())
N=int(input())

cost=[Q,H,S,D]

ans=10**18
for index,item in enumerate(cost):
    temp=item*(N*2**(2-index) if index!=3 else N//2)
    
    for jndex,jtem in enumerate(cost[:3]):
        ans=min(ans,temp+jtem*(0 if index!=3 else (N%2)*2**(2-jndex)))
    
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
cost=list(map(int,input().split()))

for i in range(4):
    cost[i]/=2**(i-2)
    if i!=3:
        cost[i]=int(cost[i])
    
N=int(input())

if min(cost)==cost[3]:
    temp=int(cost[3]*2)
    print(((N//2)*temp+(N%2)*min(cost[:3])))
else:
    print((min(cost)*N))

Submission status: Accepted

Solution code:
Q,H,S,D=map(int,input().split())
N=int(input())*4
# 量は全部4倍して計算
# 1:Q円,2:H円,4:S円,8:D円
# N*4リットル買いたい (入力の時点でN*4にしておくのでNで大丈夫)

# すべて約数なので、量が大きいほうが安くなるのであればすべてそれで置き換えたほうが良い。
# どの単位を使うかの2**4通り
P=[D,S,H,Q]
ans=10**18
for i in range(2**4):
  price=0
  amount=N
  for j in range(4):
    if (i>>j)&1:
      unit=2**(3-j)
      price+=(amount//unit)*P[j]
      amount%=unit
  if amount!=0:
    continue
  if price<ans:
    ans=price
print(ans)

Submission status: Accepted

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())

l2 = min(d, 2*s, 4*h, 8*q)
if n % 2 == 0:
    print((n // 2) * l2)
else:
    print((n // 2) * l2 + min(s, 2*h, 4*q))

Submission status: Accepted

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())
print(n//2*(min(8*q, 4*h, 2*s, d))+n%2*min(4*q, 2*h, s))

Submission status: Accepted

Solution code:
import sys
q, h, s, d = [int(i) for i in sys.stdin.readline().split()]
n = int(input())
if h > q * 2:
    h = q * 2
if s > h * 2:
    s = h * 2
if d > s * 2:
    d = s * 2
_sum = 0
ls = [(0.25, q), (0.5, h), (1, s), (2, d)]
ls.reverse()
ind = 0
while n:
    cur = ls[ind]
    _sum += cur[1] * (n // cur[0])
    n %= cur[0]
    ind += 1
print(_sum)

Submission status: Accepted

Solution code:
l=list(map(int,input().split()))
n=int(input())
a=[l[0]]
b=[2*l[0],l[1]]
c=[4*l[0],2*l[1],l[2]]
d=[8*l[0],4*l[1],2*l[2],l[3]]
ans=0
x=n//2
y=n%2
print(x*min(d)+y*min(c))

Submission status: Accepted

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

A[0]*=4
A[1]*=2
t1=10**10
for i in range(3):
   t1=min(t1,A[i])

A[0]*=2
A[1]*=2
A[2]*=2
t2=10**10
for i in range(4):
   t2=min(t2,A[i])

if(N%2==1):
    print(t2*(N//2)+t1)
else:
    print(t2*(N//2))

Submission status: Accepted

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
q,h,s,d=map(int,input().split())
n=int(input())
li=[[0.25,q],[0.5,h],[1,s]]
li.sort(key=lambda x: x[1]/x[0])
li=[[1,int(li[0][1]/li[0][0])],[2,d]]
li.sort(key=lambda x: x[1]/x[0])
# print(li)
ans=0
now=0
for i in range(2):
    ko=(n-now)//li[i][0]
    ans+=ko*li[i][1]
    now+=ko*li[i][0]
    now=int(now)
    # print(ans,now)
print(int(ans))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
Q,H,S,D=map(int,input().split())
N=int(input())
temp=min(4*Q,2*H,S,D/2)

if temp!=D/2:
    print(N*temp)
else:
    if N%2==1:
        print(N//2*D+min(4*Q,2*H,S))
    else:
        print(N//2*D)

Submission status: Accepted

Solution code:
#coding: utf-8
q,h,s,d = map(int, input().split())
n = int(input()) * 4
h = min(h,2*q)
s = min(s,2*h)
d = min(d,2*s)

price = [d,s,h,q]
#print (price)
ans = 0
for i,p in enumerate(price):
    b = int(2**(3-i))
    #print (n,b)
    ans += (n // b) * p
    n = n % b
print (ans)

Submission status: Accepted

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

def main():
	#N = int(input())
	#S = input().rstrip()
	Q,H,S,D = map(int,input().split())
	N = int(input())
	
	H = min(H, 2*Q)
	S = min(S, 2*H)
	D = min(D, 2*S)
	res = D*(N//2) + S*(N%2)
	
	print(res)
	
main()

Submission status: Accepted

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())

if d / 2 != min(4 * q, 2 * h, s, d / 2):
    print(n * min(4 * q, 2 * h, s))
else:
    if n % 2 == 0:
        print(n // 2 * d)
    else:
        print(n // 2 * d + min(4 * q, 2 * h, s))