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:
q,h,s,d = map(int, input().split())
n = int(input())
q_perf = q / 0.25
h_perf = h / 0.5
s_perf = s
d_perf = d / 2
list_amo = [0.25,0.5,1,2]
list_price = [q,h,s,d]
list_perf = [q_perf,h_perf,s_perf,d_perf]
cost = 0
ind4 = list_perf.index(min(list_perf))
ind3 = list_perf.index(min(list_perf[0:3]))
ind2 = list_perf.index(min(list_perf[0:2]))
ind1 = list_perf.index(min(list_perf[0:1]))

while n >= 2:
    cost += int((n//list_amo[ind4]) *  int(list_price[ind4]))
    n -= (n//list_amo[ind4]) * list_amo[ind4]
while n >= 1:
    cost += int((n//list_amo[ind3]) *  int(list_price[ind3]))
    n -= (n//list_amo[ind3]) * list_amo[ind3]
while n >= 0.5:
    cost += int((n//list_amo[ind2]) *  list_price[ind2])
    n -= (n//list_amo[ind2]) * list_amo[ind2]

while n >= 0.25:
    cost += int((n//list_amo[ind1]) *  list_price[ind1])
    n -= (n//list_amo[ind1]) * list_amo[ind1]

print(int(cost))

Submission status: Accepted

Solution code:
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)
print((N // 2) * D + (N % 2) * S)

Submission status: Accepted

Solution code:
cup_cost = list(map(int, input().split()))
l = int(input())

#基準を2リットルとした場合のコスト
cost = [cup_cost[0]*8, cup_cost[1]*4, cup_cost[2]*2, cup_cost[3]]

#2リットルの最小コスト
cost_2 = min(cost)

#1リットルの最小コスト
cost_1 = int(min(cost[:-1]) / 2)

#2リットル容器の必要数
cup_2 = l // 2

#1リットル容器の必要数
cup_1 = l % 2

#表示
print(cup_2*cost_2 + cup_1*cost_1)

Submission status: Accepted

Solution code:
cup_cost = list(map(int, input().split()))
cost = [cup_cost[0]*8, cup_cost[1]*4, cup_cost[2]*2, cup_cost[3]]
l = [250, 500, 1000, 2000]
A = int(input())*1000

price = 0
while True:
  if A == 0:
    break;

  if A >= 2000:
      ind = cost.index(min(cost[:]))
  elif A >= 1000:
      ind = cost.index(min(cost[:-1]))
  elif A >= 500:
      ind = cost.index(min(cost[:-2]))
  else:
      ind = cost.index(min(cost[:-3]))
      
  cup_cnt = int(A/l[ind])
  price += cup_cnt * cup_cost[ind]
  A -= l[ind] * cup_cnt
    

print(price)

Submission status: Accepted

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

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

print(D*(N//2) + S*(N%2))

Submission status: Accepted

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

q2 = q*8
h2 = h*4
s2 = s*2

k = min([q2,h2,s2,d])

q1 = q*4
h1 = h*2
r = min([q1,h1,s])

if n % 2 == 0:
    print((n//2)*k)
else:
    print((n//2)*k+r)

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

Q,H,S,D = inpl()
N = int(input())
L0_5 = min(Q*2,H)
L1   = min(L0_5*2,S)
L2 = min(L1*2,D)
ans = N//2 * L2 + (N%2) * L1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

p = sorted([(q, 8), (h, 4), (s, 2), (d, 1)], key=lambda x: x[0] * x[1])
ans = 0
for v, i in p:
    ans += n // (8 // i) * v
    n = n % (8 // i)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

one_liter = min(4*q,2*h,s)
two_liter = min(2*one_liter,d)

print(n//2 * two_liter + n%2 * one_liter)

Submission status: Accepted

Solution code:
def greedy():
    global qhsd, n
    ret = 0
    ret += (n//2)*qhsd[-1]
    ret += (n % 2)*qhsd[-2]
    return ret


qhsd = [int(x) for x in input().split()]
n = int(input())
for i in range(1, 4):
    qhsd[i] = min(qhsd[i-1]*2, qhsd[i])
print(greedy())

Submission status: Accepted

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

half = min(2 * q, h)
one = min(2 * half, s)
two = min(2 * one, d)

l = zip([2, 1, 0.5, 0.25], [two, one, half, q])

ans = 0
rest = n
for vol, cost in l:
    ans += (rest // vol) * cost
    rest %= vol
    if rest == 0:
        print(ans)
        break

Submission status: Accepted

Solution code:
def a_ice_tea_store(Q, H, S, D, N):
    record_low_1liter = min(4 * Q, 2 * H, S)  # 1リットル買うための最小の値段
    if record_low_1liter * 2 <= D:  # 2リットルサイズは買わなくていい
        ans = N * record_low_1liter
    else:
        buy_2liter = N // 2
        buy_1liter = N % 2
        ans = buy_1liter * record_low_1liter + buy_2liter * D
    return ans

Q, H, S, D = [int(i) for i in input().split()]
N = int(input())
print(a_ice_tea_store(Q, H, S, D, N))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    qhsd=list(map(int,input().split(" ")))
    n=int(input())
    for i in range(3):
        if qhsd[i+1]>qhsd[i]*2: qhsd[i+1]=qhsd[i]*2
    res=(n%2)*qhsd[2]+(n//2)*qhsd[3]
    print(int(res))

main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a,b,c,d=map(int,input().split())
n=int(input())
l=min(a*4,b*2,c)
ll=min(l*2,d)
print((n//2)*ll+(n%2)*l)

Submission status: Accepted

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

if n % 2 == 1:
    qua = 4 * q * n
    hal = 2 * h * n
    one = s * n
    two_1 = d * (n//2) + s
    two_2 = d * (n//2) + 2*h
    two_3 = d * (n//2) + 4*q
    
    print(min(qua, hal, one, two_1, two_2, two_3))
    
else:
    qua = 4 * q * n
    hal = 2 * h * n
    one = s * n
    two = d * (n//2)
    
    print(min(qua, hal, one, two))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
Q,H,S,D=[int(i) for i in input().split()]
N=int(input())


L1 = min(min(Q*4,H*2),S)
L2 = min(L1*2,D)


res = (N//2)*L2 + (N%2)*L1
print(res)

Submission status: Accepted

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

h=min(h,q+q)
s=min(s,h+h)
d=min(d,s+s)

n=int(input())

print(n//2*d+n%2*s)

Submission status: Accepted

Solution code:
def main():
  t = input().split(" ")
  Q, H, S, D = int(t[0]), int(t[1]), int(t[2]), int(t[3])
  N = int(input())
  if Q*4 < S:
    S = Q*4
  if H*2 < S:
    S = H*2
  if S*2 < D:
    D = S*2
  ans = (N//2) * D
  ans += (N%2) * S
  print(ans)
main()

Submission status: Accepted

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


def main():
    q, h, s, d = list(map(int, input().split()))
    n = int(input())

    # See:
    # https://www.youtube.com/watch?v=9OiB8ot3a0w
    x = min(4 * q, h * 2, s)
    print(min(n * x, d * (n // 2) + n % 2 * x))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

t2=min([a*8,b*4,c*2,d*1])

ans=(n//2)*t2
n=n%2

t1=min([a*4,b*2,c*1])
ans+=n*t1

print(ans)

Submission status: Accepted

Solution code:



def main():
    weight = 8,4,2,1

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

    
#    print(q,h,s,d,n)
    s = min(4*q, h*2, s)

#    print(q,h,s,d,n)
#    print(n%2,n//2 )

    div = n//2
    mod = n%2
#    print(d,m)
    sum = 0
    if mod == 1:
        sum = sum + s

#    print( s*2, d)
    sum = sum + div * min(s*2 , d)

    print(sum)
main()

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
if N % 2 == 0:
    ans = min(8*Q, 4*H, 2*S, D)*N//2
else:
    ans = min(8*Q, 4*H, 2*S, D)*(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())

if Q*2<=H:
  H=Q*2

if H*2<=S:
  S=H*2

if S*2<=D:
  D=S*2 

print(N//2*D+N%2*S)

Submission status: Accepted

Solution code:
# 4で1リットル
q, h, s, d = map(int, input().split())
n = int(input())
q = q * 4
h = h * 2

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

Submission status: Accepted

Solution code:
Q, H, S, D = [int(_) for _ in input().split()]
N = int(input())

l = min(Q*4, H*2, S)
l2 = min(D, l*2)

# print(l2, l)

r = (N // 2) * l2 + (N % 2) * l

print(r)

Submission status: Accepted

Solution code:
arr = map(int,raw_input().split())

l1 = min(arr[0]*4,arr[1]*2,arr[2])
l2 = min(l1*2,arr[3])
n = int(input())

ans = n/2*l2 + n%2 * l1
print ans

Submission status: Accepted

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

q = Q*4
h = H*2
s = S
d = D/2

if min(q,h,s,d)==d:
    if N%2 == 0:
        money = D*(N//2)
    else:
        money = (N//2)*D + min(q,h,s)
else:
    money = min(q,h,s)*N

print(int(money))

Submission status: Accepted

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

if n % 2 == 0:
	print(min(two * (n // 2), one * n))
else:
	print(min(two * (n // 2) + one, one * n))

Submission status: Accepted

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

cost_per_two_liters = [8*Q,4*H,2*S,D]
res = int(N/2) * min(cost_per_two_liters)
if N % 2 == 0:
    print(res)
else:
    res += min([4*Q,2*H,S])
    print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
q,h,s,d = map(int,input().split())
n = int(input())
litter = [q*4,h*2,s]
litter.sort()
twolitter = [q*8,h*4,s*2,d]
twolitter.sort()
total = 0
if n%2 == 0:
	total = (n//2)*twolitter[0]
else:
	total = (n//2)*twolitter[0]+litter[0]

print(total)

Submission status: Accepted

Solution code:
Q,H,S,D=map(int,raw_input().split())
N=input()
a=min([Q*4,H*2,S])
b=float(D)/2

ans=0
if b<a:
	ans+=N/2*D
	amari=N%2
	ans+=amari*a
else:
	ans=N*a
print ans

Submission status: Accepted

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

Submission status: Accepted

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

one_litter = [4*q,2*h,s]
ans += n * min(one_litter)
print(ans)

Submission status: Accepted

Solution code:

def main():
    q, h, s, d = map(int, input().split())
    n = int(input()) * 100
    h = min(h, 2*q)
    s = min(s, 2*h)
    d = min(d, 2*s)
    ans = 0
    vals = [(200, d), (100, s), (50, h), (25, q)]
    for m, val in vals:
        c = n // m
        n -= m * c
        ans += val*c
    print(int(ans))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    q, h, s, d = map(int, input().split())
    n = int(input())
    
    x, y = n // 2, n % 2
    p_x = min(8*q, 4*h, 2*s, d) * x
    p_y = min(4*q, 2*h, s) * y
    
    print(p_x+p_y)
    
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
Q, H, S, D=map(int,input().split())
N=int(input())
Q_1liter=4*Q
H_1liter=2*H
S_1liter=S
min_QHS=min(Q_1liter,H_1liter,S_1liter)
min_QHS2=min(min_QHS*2,D)
if N%2==0:
    output=min_QHS2*int(N/2)
    print(int(output))
else:
    output=(int(N/2)*min_QHS2+min_QHS)
    print(int(output))

Submission status: Accepted

Solution code:
Q, H, S, D=map(int,input().split())
N=int(input())
Q_1liter=4*Q
H_1liter=2*H
S_1liter=S
min_QHS=min(Q_1liter,H_1liter,S_1liter)
min_QHS2=min(min_QHS*2,D)
if N%2==0:
    output=min_QHS2*(N//2)
    print(int(output))
else:
    output=((N//2)*min_QHS2+min_QHS)
    print(int(output))

Submission status: Accepted

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

N = int(input())

if Q*2<H: H=2*Q
if H*2<S: S=2*H
if S*2<D: D=2*S
    
ans = (N//2)*D
if N%2==1: ans += 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)
b=min(a*2,d)
print(a*(n%2)+b*(n//2))

Submission status: Accepted

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

Submission status: Accepted

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

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)
if 2*s<d:
    print(n*s)
else:
    cnt=n%2
    cnt_2=n//2
    print(cnt_2*d+cnt*s)

Submission status: Accepted

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

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

print(A)

Submission status: Accepted

Solution code:
def read():
    return int(input())


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


def readmap():
    return map(int, input().split())


Q, H, S, D = readmap()
N = read()

ls = [4 * Q, 2 * H, S]
idx = ls.index(min(ls))

if idx == 0:
    S = 4 * Q
elif idx == 1:
    S = 2 * H

if 2 * S <= D:
    print(S * N)
else:
    print((N // 2) * D + (N % 2) * S)

Submission status: Accepted

Solution code:
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()

#0.25リットルサイズ
q = int(arr_data[0][0])

#0.5リットルサイズ
h = int(arr_data[0][1])

#1リットルサイズ
s = int(arr_data[0][2])

#2リットルサイズ
d = int(arr_data[0][3])

#買いたいicetea
n = int(arr_data[1][0])

arr = [q * 4, h * 2, s, d / 2]


if n == 1:
    
    kingaku = min(arr[0:3])
    
else:
    
    if arr.index(min(arr)) == 3:
        
        kingaku = d * (n // 2)
        n -= 2 * (n // 2)
        kingaku += n * min(arr[0:3])
    else:
        kingaku = n * min(arr)
        
    
print(kingaku)

Submission status: Accepted

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

ans = int(0)
if d < 2*s and d < 4*h and d < 8*q and n >= 2 :
    ans += int(n/2)*d
    n %= 2

if s < 2*h and s < 4*q:
    ans += n*s
elif h < 2*q:
    ans += n*2*h
else:
    ans += n*4*q

print(ans)

Submission status: Accepted

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

    yen = 0
    A = [4*Q, 2*H, S]
    if D/2 < min(A):
        if N%2==0:
            return D * N//2
        else:
            return D*(N-1)//2 + min(A)
    else:
        return N * min(A)

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

Submission status: Accepted

Solution code:
a,b,c,d = list(map(int,input().split()))
n = int(input())
i = min(c,2*b,4*a)
j = min(d,2*i)
print(n//2*j+n%2*i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
q,h,s,d=map(int,input().split())
n=int(input())
h=min(h,2*q)
s=min(s,2*h)
if 2*s<=d:
    print(n*s)
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())
cospa=[[q/0.25,0.25,q],[h/0.5,0.5,h],[s,1.0,s],[d/2,2.0,d]]
cospa.sort()
money=0
for i in range(4):
  if(n>=cospa[i][1]):
    x=int(n//cospa[i][1])
    money+=int(x*cospa[i][2])
    n%=cospa[i][1]
print(int(money))

Submission status: Accepted

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

l05 = min(2*Q, H)
l10 = min(l05*2, S)
l20 = min(l10*2, D)

print(N//2*l20 + N%2*l10)

Submission status: Accepted

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

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def main():
    q, h, s, d = map(int, input().split())
    n = int(input())
    l = min(4 * q, 2 * h, s)
    if 2 * l > d:
        print((n // 2) * d + (n % 2) * l)
    else:
        print(n * l)

main()

Submission status: Accepted

Solution code:
q,h,s,d = (int(i) for i in input().split())
n = int(input())
x = min(4*q,2*h,s)
y = min(2*x,d)
print((y*(n-n%2)//2)+x*(n%2))

Submission status: Accepted

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

Submission status: Accepted

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

l05 = min(Q*2, H)
l10 = min(l05*2, S)
l20 = min(l10*2, D)

print(int((N//2*l20) + (N%2*l10)))

Submission status: Accepted

Solution code:
Q, H, S, D = map(int, input().split())
N = int(input())
Q_S, H_S, D_S = Q*4, H*2, D/2

if min(Q_S,H_S,S,D_S) == Q_S:
    print(Q_S*N)
elif min(Q_S,H_S,S,D_S) == H_S:
    print(H_S*N)
elif min(Q_S,H_S,S,D_S) == S:
    print(S*N)
else:
     if min(Q_S,H_S,S) == Q_S:
         print(D*(N//2)+Q_S*(N%2))
     elif min(Q_S,H_S,S) == H_S:
         print(D*(N//2)+H_S*(N%2))
     elif min(Q_S,H_S,S) == S:
         print(D*(N//2)+S*(N%2))

Submission status: Accepted

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

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

# ans=(N//2)*min(2*Q,2*H,2*S,D)+(N%2)*min(Q,H,S)

print(ans)

Submission status: Accepted

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

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

# ans=(N//2)*min(2*Q,2*H,2*S,D)+(N%2)*min(Q,H,S)

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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]
l2min=l2.index(min(l2))
l1min=l1.index(min(l1))

ans,rest=divmod(N,2)
ans=ans*l2[l2min]+rest*l1[l1min]
print(ans)

Submission status: Accepted

Solution code:
inputstr = input().split()
#*1000
QHSD = [[250,int(inputstr[0])],[500,int(inputstr[1])],[1000,int(inputstr[2])],[2000,int(inputstr[3])]]
N = int(input()) * 1000

QHSDs = sorted(QHSD, key=lambda x: x[1]/x[0])

amari = N
ans = 0
for row in QHSDs:
    ans += (amari // row[0]) * row[1]
    amari %= row[0]
    
print(ans)

Submission status: Accepted

Solution code:
a = input().split(" ")
b = list(map(int, a))
c = int(input())
ans = 0
r = min([b[0] * 4, b[1] * 2, b[2]])
r2 = min([r * 2, b[3]])
if c % 2 == 1:
    ans += r
    c -= 1
ans += r2 * (c // 2)
print(int(ans))

Submission status: Accepted

Solution code:
b=list(map(int,input().split()))
c = int(input())
ans = 0
r = min([b[0]*4, b[1]*2, b[2]])
r2 = min([r*2, b[3]])
if c % 2 == 1:
	ans += r
	c -= 1
ans += r2 * (c // 2)
print(ans)

#if c%2==1:
#	print(int(((c-1)/2)*r2+r))
#else :
#	print(int((c/2)*r2))

Submission status: Accepted

Solution code:
b=list(map(int,input().split()))
c = int(input())
ans = 0
r = min([b[0]*4, b[1]*2, b[2]])
r2 = min([r*2, b[3]])
#if c % 2 == 1:
#    ans += r
#   c -= 1
#ans += r2 * (c / 2)
#print(int(ans))

if c%2==1:
	print(((c-1)//2)*r2+r)
else :
	print((c//2)*r2)

Submission status: Accepted

Solution code:
b=list(map(int,input().split()))
c = int(input())
ans = 0
r = min([b[0]*4, b[1]*2, b[2]])
r2 = min([b[0]*8,b[1]*4,b[2]*2, b[3]])
#if c % 2 == 1:
#    ans += r
#   c -= 1
#ans += r2 * (c / 2)
#print(int(ans))

if c%2==1:
	print(((c-1)//2)*r2+r)
else :
	print((c//2)*r2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
q,h,s,d=[int(i) for i in input().split()]
n=int(input())

qr,hr,sr,dr=q*4,h*2,s,d/2
a=[[qr,q,0.25],[hr,h,0.5],[sr,s,1],[dr,d,2]]

a.sort()
k=0
if a[0][2]<2:
  k = n * a[0][0]
else:
  k=  (n//2) * a[0][1] + (n%2) *a[1][0]
  
print(round(k))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    rt = 0
    Q,H,S,D = map(int,input().split(" "))
    N = float(input())
    count_1 = N//2
    count_2 = (N-count_1*2)//1
    count_3 = (N-count_1*2-count_2)*100//50
    count_4 = (((N-count_1*2-count_2)*100)-50*count_3)//25
    if count_1:
        rt+=int(count_1)*min(2*S,D,4*H,8*Q)
    if count_2:
        rt+=int(count_2)*min(S,2*H,4*Q)
    if count_3:
        rt+=min(H,2*Q)*int(count_3)
    if count_4:
        rt+=Q*int(count_4)
    print(int(rt))

if __name__=="__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

if 2*q < h:
    h = 2*q

if 2*h < s:
    s = 2*h

if 2*s < d:
    d = 2*s

print(math.floor(n/2)*d + n%2*s)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import math
Q, H, S, D = map(int, input().split())
N = int(input())

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

cost1 = N * one
cost2 = N//2 * two + (N %2) * one
#print(one, two, cost1, cost2)
# data = [Q*4, H*2, S, D/2]
# nums = [0.25, 0.5, 1, 2]
# price = [Q, H, S, D]
# data_index = sorted(range(len(data)), key=lambda k: data[k])
# #print(data,data_index)
# ans = 0
# for i in range(4):
#     ans += N//nums[data_index[i]] * price[data_index[i]]
#     N -= N//nums[data_index[i]] * nums[data_index[i]]
print(min(cost1, cost2))

Submission status: Accepted

Solution code:
money=list(map(int,input().split()))
N=int(input())
best_over2=int(min(8*money[0],4*money[1],2*money[2],money[3]))
best_under1=int(min(4*money[0],2*money[1],money[2]))
if(N==1):
    print(best_under1)
elif(N%2==0):
    print((N//2)*best_over2)
elif(N%2!=0):
    print((N//2)*best_over2+best_under1)

Submission status: Accepted

Solution code:
line = map(int, raw_input().split())
n = int(raw_input()) * 4 

for i in range(3):
    line[i+1] = min(line[i+1], 2*line[i])

res = 0 
while n > 0:
    for i in range(3, -1, -1):
        k = n // (2**i)
        if k > 0:
            res += k * line[i]
            n -= k*(2**i)
            break

print(res)

Submission status: Accepted

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

X = min(4 * Q, 2 * Q + H, 2 * H, S)

if X * 2 < D:
    ans = N * X
else:
    if N % 2 == 0:
        ans = N // 2 * D
    else:
        ans = N // 2 * D + X
print(ans)

Submission status: Accepted

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

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

print(s*n if d>s*2 else d*(n//2)+s*(n%2))

Submission status: Accepted

Solution code:
import numpy as np

Q, H, S, D = map(int, input().split())
# values = np.array([min(2*min(2*Q, H), S), D])
# # 評価値
# capacities = np.array([1.0, 2.0])
# eval = values / capacities
N = int(input())
# nums = np.zeros(2)
#
# sorted_eval_index = np.argsort(eval)
#
# # N = 0.25 * Q_n + 0.5 * H_n + 1 * S_n + 2 * D_n
#
# for index in list(sorted_eval_index):
#     if N/capacities[index] >= 1:
#         nums[index] += int(N/capacities[index])
#         N -= nums[index] * capacities[index]
#
# print(int(np.sum(values*nums)))

print(int(int(N/2)*(min(2*min(2*min(2*Q, H), S), D))+(N % 2)*(min(2*min(2*Q, H), S))))

Submission status: Accepted

Solution code:
Q, H, S, D,= map(int, raw_input().split())
N = int(input())
if Q*2 > H:
    M1 = H
else:
    M1 = Q*2

if  M1*2 > S:
    M = S
else:
    M = M1*2
if M*2 < D:
    print(M*N)
else:
    if N%2 == 0:
        print(D*(N//2))
    else:
        print(D*(N//2) + M)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
 
sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9 + 7
 
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
 
 
def main():
    a = sorted(list(zip(LI(),[0.25,0.5,1.0,2.0])), key=lambda x: x[0]/x[1])
    n = I() * 4
    r = 0
    for i in range(4):
        k,t = a[i]
        t = int(t*4)
        if n >= t:
            r += k * (n//t)
            n %= t
 
    return r
 
print(main())

Submission status: Accepted

Solution code:
value = list(map(int,input().split()))
l = int(input())
l *= 100
rittoru = [25, 50, 100, 200]
m = value[0] * 2
total = 0

for i in range(1, 4):
    if m < value[i]:
        value[i] = m
        m *= 2
    else :
        m = value[i] * 2

for i in range(4)[::-1]:
    hon = l // rittoru[i]
    l %= rittoru[i]
    total += hon * value[i]

print (total)

Submission status: Accepted

Solution code:
Value = list(map(int,input().split()))
#Value[0] = Q,Value[1] = H,Value[2] = S…
N = int(input())
N = N*100
res = 0
l = [25,50,100,200]

for i in range(3):
    if Value[i]*2 < Value[i+1]:
        Value[i+1] = Value[i]*2

for i in range(4)[::-1]:
    n = N//l[i]
    N = N%l[i]
    res += Value[i]*n

print(res)

Submission status: Accepted

Solution code:
q,h,s,d=[int(x) for x in input().split()]
o=min(4*q,2*h,s)
t=min(o*2,d)
n=int(input())
print(n%2*o+n//2*t)

Submission status: Accepted

Solution code:
p = list(map(int, input().split()))
N = 4 * int(input())

p[1] = min(p[1], p[0] * 2)
p[2] = min(p[2], p[1] * 2, p[0] * 4)
p[3] = min(p[3], p[2] * 2, p[1] * 4, p[0] * 8)

k = 8
ret = 0
for m in p[::-1]:
    ret += N // k * m
    N %= k
    k //= 2

print(ret)

Submission status: Accepted

Solution code:
from operator import itemgetter
 
a=list(map(int,input().split()))
n=4*int(input())
p=[]
for i in range(4):
    p.append([2**i,a[i]*4,(a[i]*4)/2**i])
 
 
p=sorted(p,key=itemgetter(2))
 
ans=0
 
for i in range(4):
    t=n//p[i][0]
    ans += t*p[i][1]
    n -= t*p[i][0]
 
print(ans//4)

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def main():
    Q, H, S, D = map(int, input().split())
    N = int(input())
    ans = INF
    ans = min(ans, N * 4 * Q)
    ans = min(ans, N * 2 * H)
    ans = min(ans, N * 1 * S)
    d = N // 2
    if N % 2 == 0:
        ans = min(ans, d * D)
    else:
        ans = min(ans, d * D + Q * 4)
        ans = min(ans, d * D + H * 2)
        ans = min(ans, d * D + S)

    print(ans)


if __name__ == '__main__':
    main()

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)
if D>=S*2 :
    print(S*N)
else:
    ans=0;
    if N%2==1:
        ans+=S
    
    ans+=(N//2)*D
    print(ans)

Submission status: Accepted

Solution code:
input1 = input("").split(" ")
Q = int(input1[0])
H = int(input1[1])
S = int(input1[2])
D = int(input1[3])
N = int(input(""))

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
q,h,s,d = map(int, input().split())
n = int(input())
s = min(s, 2*min(h, 2*q))
if 2*s >= d:
    print(d*(n//2)+s*(n%2))
else:
    print(s*n)