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())

cands = [(0, Q*8), (1, H*4), (2, S*2), (3, D)]
cands = sorted(cands, key=lambda x: (x[1], x[0]))
if cands[0][0] == 3:
    if N % 2 == 1:
        dcost = N // 2 * D
        if cands[1][0] == 2:
            print(dcost + S)
        elif cands[1][0] == 1:
            print(dcost + 2 * H)
        else:
            print(dcost + 4 * Q)
    else:
        print(N // 2 * D)
elif cands[0][0] == 2:
    print(N * S)
elif cands[0][0] == 1:
    print(N * 2 * H)
elif cands[0][0] == 0:
    print(N * 4 * Q)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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(8*q, 4*h, 2*s, d))
if n % 2 == 1:
  ans += min(4*q, 2*h, s)
print(int(ans))

Submission status: Accepted

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

efficient_num,efficient_cost = 0,8*Q
if(efficient_cost > 4*H): efficient_num,efficient_cost = 1,4*H
if(efficient_cost > 2*S): efficient_num,efficient_cost = 2,2*S
if(efficient_cost > D): efficient_num,efficient_cost = 3,D

#残りが0L or 1Lとなるまでコスパいい商品を買う
min_cost = 0

if(N%2 == 0):
 if(efficient_num == 0): min_cost = int(N/0.25)*Q
 elif(efficient_num == 1): min_cost = int(N/0.50)*H
 elif(efficient_num == 2): min_cost = N*S
 elif(efficient_num == 3): min_cost = (N//2)*D
 #残り0L

else:
 N = 2*(N//2)
 if(efficient_num == 0): min_cost = int(N/0.25)*Q
 elif(efficient_num == 1): min_cost = int(N/0.50)*H
 elif(efficient_num == 2): min_cost = N*S
 elif(efficient_num == 3): min_cost = (N//2)*D
 #残り1L
 #2L以外のコスパいいので残り1Lを買う
 efficient_num,efficient_cost = 0,8*Q
 if(efficient_cost > 4*H): efficient_num,efficient_cost = 1,4*H
 if(efficient_cost > 2*S): efficient_num,efficient_cost = 2,2*S
  
 if(efficient_num == 0): min_cost += int(1/0.25)*Q
 elif(efficient_num == 1): min_cost += int(1/0.50)*H
 elif(efficient_num == 2): min_cost += 1*S
    
print(min_cost)

Submission status: Accepted

Solution code:
import math as ma
l = list(map(int,input().split()))
N = int(input())
N *= 4
dp = [0 for i in range(9)]
for i in range(1,9):
    dp[i] = min([dp[i-2**j]+l[j] for j in range(min(4,int(ma.log2(i)+1)))])
ans = float('inf')
for i in range(1,9):
    ans = min(ans,N//i*dp[i] + dp[N-N//i*i])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
q,h,s,d = map(int,input().split())
r = [q,h,s,d]
n = int(input())*4
l = [q,h/2,s/4,d/8]
v = [1,2,4,8]
cost = 0
while n:
  now = l.index(min(l))
  cost += n//v[now] * r[now]
  n %= v[now]
  v.pop(now)
  r.pop(now)
  l.pop(now)
print(cost)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
Q, H, S, D = map(int, input().split())
N = int(input())
q, h, s, d = 4 * Q, 2 * H, S, D / 2
if d == min(q, h, s, d) and N >= 2:
    res = D * (N // 2) + (N % 2) * min(q, h, s)
else:
    res = N * min(q, h, s)
print(res)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

# N が整数なので、整数リットルずつしか買えない。
# 0.25リットルと0.5リットルを1リットルあたりの価格に換算して、最小のものを S とする
S = min(4*Q, 2*H, S)

if D >= 2*S:
    ans = N * S
else:
    ans = N//2 * D + N%2 * S

print(ans)

Submission status: Accepted

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

# N が整数なので、1リットルずつしか買えない。
# 0.25リットルと0.5リットルを1リットルあたりの価格に換算して、最小の価格を S とする
S = min(4*Q, 2*H, S)

if D >= 2*S:
    ans = N * S
else:
    ans = N//2 * D + N%2 * S

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/agc019/tasks/agc019_a

import itertools
import collections
import bisect
import sys
input = sys.stdin.readline

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

if __name__ == '__main__':
    main()

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())
a = [q*8,h*4,s*2,d]
min_s = min(a[:3]) // 2
min_d = min(a)
b,c = divmod(n,2)
print(b*min_d + c * min_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()) # yen
N = int(input()) # L want
min1 = min(2 * Q, H)
min2 = min(2 * min1, S)
min3 = min(2 * min2, D)
print(N // 2 * min3 + N % 2 * min2)

Submission status: Accepted

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

Submission status: Accepted

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

a = min(8*Q,4*H,2*S,D)
ans = 0

ans += a * (N//2)
if N % 2 :
    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())

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

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)
a,b = divmod(N,2)
print(a*d + b*s)

Submission status: Accepted

Solution code:
QHSD = [int(i) for i in input().split()]
N = int(input())

ratio = [0]*4

ratio[0] = QHSD[0]*4
ratio[1] = QHSD[1]*2
ratio[2] = QHSD[2]
ratio[3] = QHSD[3]/2

res = 0

m_index = ratio.index(min(ratio))

if m_index == 3:
    res += int(N/2) * QHSD[3]
    N -= int(N/2) * 2


m_index = ratio[:3].index(min(ratio[:3]))

if m_index == 0:
    res += int(N/0.25) * QHSD[0]
elif m_index == 1:
    res += int(N/0.5) * QHSD[1]
elif m_index == 2:
    res += N * QHSD[2]


print(res)

Submission status: Accepted

Solution code:
  
def solve():
  q,h,s,d= (int(i) for i in input().split())
  n = int(input())
  Ltanka = [4*q,2*h,s]
  L2tanka = [8*q,4*h,2*s,d]
  ans = 0
  while n != 0:
   if n == 1:
    ans += min(Ltanka)
    n-= 1
   else:
    times =  n//2
    ans += times*min(L2tanka)
    n -= times *2
  return ans
  
if __name__ == '__main__':
  print(solve())

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))
n = int(input())
B = [0.25, 0.5, 1, 2]

C = []
for a, b in zip(A, B):
    c = a / b
    C.append([a, b, c])
    
C.sort(key = lambda x: x[2])

ans = 0
for i in range(len(C)):
    x = n // C[i][1]
    ans += int(x * C[i][0])
    n -= x * C[i][1]
    
print(ans)

Submission status: Accepted

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

a = (n // 2 * d) + n % 2 * int(min(s, h // 0.5, q // 0.25))
b = n * int(min(s, h // 0.5, q // 0.25))
ans = min(a, b)
print(int(ans))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())
q1 = q * 4
h1 = h * 2
ans = 0
if n >= 2:
    buy = min([q1 * 2, h1 * 2, s * 2, d]) * (n // 2)
    n -= n // 2 * 2
    ans += buy
if n > 0:
    ans += min([q1, h1, s])
print(ans)

Submission status: Accepted

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

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

if one * 2 < two:
    print(one * N)

else:
    tmp = N // 2
    print(tmp * two + N%2 * one)

Submission status: Accepted

Solution code:
import collections
import itertools
import numpy as np
import sys
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

A,B,C,D = IL()
N = I()*1000

a = A/250
b = B/500
c = C/1000
d = D/2000
score = [a,b,c,d]
val = {a:(A,250),b:(B,500),c:(C,1000),d:(D,2000)}

score.sort()

ans = 0
for i in score:
    tmp = N//val[i][1]
    N -= tmp*val[i][1]
    ans += tmp*val[i][0]
print(ans)

Submission status: Accepted

Solution code:
q,h,s,r = map(int,input().split())
n = int(input())
a = n//2
b = n%2
x = min(q*8,h*4,s*2,r)
if b==0:
    print(x*a)
else:
    y = min(q*4,h*2,s)
    print(x*a+y)

Submission status: Accepted

Solution code:
val = [int(i) for i in input().split()]
N = int(input())*4

li = [1,2,4,8]

m = [0]*4
for i in range(4):
    m[i] = val[i]*(2**(4-i-1))

ans = 0
while N != 0:
    j = m.index(min(m))
    ans += N//li[j]*val[j]
    N = N%li[j]
    m.pop(j)
    li.pop(j)
    val.pop(j)

print(ans)

Submission status: Accepted

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

q_2l = q*8
h_2l = h*4
s_2l = s*2
ans = (n - n%2) //2 * min(q_2l, h_2l, s_2l, d) 
ans += (n % 2) * min(q_2l, h_2l, s_2l) // 2 # 奇数リットルの場合
print(ans)

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())
a = [q,h,s,d]
b = [4*q,2*h,s]
c = b.index(min(b))

if b[c]*2 > d:
    ans = n//2 * d
    if n % 2 == 1:
        ans += b[c]
else:
    ans = n*b[c]
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(two*(N//2)+one*(N%2))

Submission status: Accepted

Solution code:
def solve(Q, H, S, D, N):
    return min(
        N * Q * 4,
        N * H * 2,
        N * S,
        (N // 2) * D + min(S * (N % 2), H * 2 * (N % 2), Q * 4 * (N % 2))
    )

if __name__ == "__main__":
    Q, H, S, D = tuple(map(int, input().split(" ")))
    N = int(input())
    print(solve(Q, H, S, D, N))

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) * s + (n // 2) * d)

Submission status: Accepted

Solution code:
q, h, s, d = 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())
h = min(h, q * 2)
s = min(s, h * 2)
if (d > s * 2):
  print(n * s)
elif (n % 2):
  print((n // 2) * d + s)
else:
  print((n // 2) * d)

Submission status: Accepted

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())
q1 = q / 0.25
h1 = h / 0.5
s1 = s / 1
d1 = d / 2
minx = min(q1, h1, s1, d1)
a = [[q1, 0.25], [h1, 0.5], [s1, 1], [d1, 2]]
a.sort()
if n % 2 != 0 and a[0][1] == 2:
    print(int((n - 1) // 2 * d) + int(a[1][0]))
else:
    if minx == d1:
        print(int(d * n // 2))
    else:
        print(int(minx * n))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
ar = list(map(int,input().split(" ")))
br = [ar[0] * 8,ar[1] * 4,ar[2] * 2,ar[3]]
a = int(input())
ar[0] *= 4
ar[1] *= 2
del ar[3]
count = 0
if a >= 2:
    count += min(br) * (a // 2)
    if a % 2 == 1:
        count += min(ar)
else:
    count += min(ar)
print(count)

Submission status: Accepted

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

"""
・速攻自力AC
"""

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, initial=1)
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

q, h, s, d = MAP()
n = INT()

best1L = min(q*4, h*2, s)
best2L = min(d, best1L*2)

if n % 2 == 0:
    print(best2L * (n//2))
else:
    print(best2L * (n//2) + best1L)

Submission status: Accepted

Solution code:
q,h,s,d = map(int,input().split())
N = int(input())
qp,hp,dp = q*4,h*2,d//2
i = 0
ans = 0
if dp<hp and dp<qp and dp<s:
    ans = d*(N//2)
    N %= 2
ans += min(s,min(hp,qp))*N
print(int(ans))

Submission status: Accepted

Solution code:
qhsd=list(map(int, input().split()))
N=int(input())
# ls0=[0.25, 0.5, 1.0, 2.0]
# ls=[]
# for i in range(4):
# 	ls.append([8//(2**i)*qhsd[i],ls0[i],qhsd[i]])
# ls.sort()
# # print(ls)

# ans=0
# for i in range(4):
# 	if N<ls[i][1]:
# 		continue
# 	ans+=int(N//ls[i][1]*ls[i][2])
# 	N=int(N-N//ls[i][1]*ls[i][1])
# 	if N==0:
# 		break
# 	# print(i, ans, N)
# print(ans)

print((N//2)*min(8*qhsd[0],4*qhsd[1],2*qhsd[2],1*qhsd[3])+(N%2)*min(4*qhsd[0],2*qhsd[1],1*qhsd[2]))

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, 4*Q)
D = min(D, 2*S, 4*H, 8*Q)

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

Submission status: Accepted

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


def main():
    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)
        ans += min(4 * q, 2 * h, s)

    print(int(ans))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
qhsd = list(map(int, input().split()))
n = int(input()) * 4

m_qhsd = [[qhsd[3], 3], [qhsd[2] * 2, 2], [qhsd[1] * 4, 1], [qhsd[0] * 8, 0]]
qs = [1, 2, 4, 8]
m_qhsd.sort()
ans = 0
while n != 0:
    tmp = m_qhsd.pop(0)
    ans += n // qs[tmp[1]] * qhsd[tmp[1]]
    n %= qs[tmp[1]]
print(ans)

Submission status: Accepted

Solution code:
a=list(map(int,input().split()))
n=4*int(input())
for i in range(4):
    a[i]=a[i]*(2**(3-i))
h=a[:]
h.sort()
c=0
for i in range(4):
    p=a.index(h[i])
    s=h[i]//(2**(3-p))
    d=n//(8//(2**(3-p)))
    c+=s*d
    n-=d*int(8//(2**(3-p)))
print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()


q, h, s, d = LI()
n = I()

min_1 = min(4 * q, h * 2, s)
min_2 = min(2 * min_1, d)

print(n // 2 * min_2 + (n % 2) * min_1)

Submission status: Accepted

Solution code:
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()


# 1, 2, 4, 8
amount = [4 * x for x in LI()]
n = I() * 4

performance = [(amount[i] // (2 ** i), i) for i in range(4)]
performance.sort()

bought_tea, fee = 0, 0
for i in range(4):
    tea = performance[i][1]
    litre = 2 ** tea
    q = (n - bought_tea) // litre
    bought_tea += q * litre
    fee += q * amount[tea]

print(fee // 4)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a1,a2,a4,a8 = map(int, input().split())
n = int(input())
MIN_2 = min(a1*8,a2*4,a4*2,a8)
MIN_1 = min(a1*4,a2*2,a4)
a = (n // 2) 
b = (n - a*2) // 1
print(a*MIN_2+b*MIN_1)

Submission status: Accepted

Solution code:
Q, H, S, D = map(int, input().split()) # 0.25 0.5 1 2
N = int(input())

one_l = min([4 * Q, 2 * Q + H, H * 2, S])
two_l = min([one_l * 2, D])

if N % 2 == 0:
    print(two_l * (N // 2))
else:
    print(two_l * (N // 2) + one_l)

Submission status: Accepted

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

Dmin = min(D,2*S,4*H,8*Q)
Smin = min(S,2*H,4*Q)
N = int(input())
print((N // 2)*Dmin + (N % 2) *Smin)

Submission status: Accepted

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

compare2 = [Q*8, H*4, S*2, D]
Q2, H2, S2, D2 = compare2

compare3 = [Q*8, H*4, S*2]
Q3, H3, S3 = compare3

ans = 0
if D2 == min(compare2):
    ans = (N // 2) * D
    N %= 2

if Q3 == min(compare3):
    ans += N * Q * 4
elif H3 == min(compare3):
    ans += N * H * 2
elif S3 == min(compare3):
    ans += N * S

print(ans)

Submission status: Accepted

Solution code:
S,M,L,B=map(int,input().split())

N=int(input())

if min(8*S,4*M,2*L,B)==8*S:
    print(4*S*N)
elif min(8*S,4*M,2*L,B)==4*M:
    print(2*M*N)
elif min(8*S,4*M,2*L,B)==2*L:
    print(L*N)
elif min(8*S,4*M,2*L,B)==B:
    if N%2==0:
        print(B*N//2)
    else:
        if min(8*S,4*M,2*L)==8*S:
            print(B*(N//2)+4*S)
        elif min(8*S,4*M,2*L)==4*M:
            print(B*(N//2)+2*M)
        elif min(8*S,4*M,2*L)==2*L:
            print(B*(N//2)+L)

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())
plice_dict = {0.25: Q, 0.5: min(2*Q, H), 1: min(4*Q, 2*H, S), 2: min(8*Q, 4*H, 2*S, D)}
result = 0

while N != 0:
    if N > 2:
        result += plice_dict[2] * (N - 2) // 2 if (N - 2) % 2 == 0 else plice_dict[2] * (N - 3) // 2 + plice_dict[1]
        N = 2
    elif N == 2:
        result += plice_dict[2]
        N -= 2
    elif N >= 1:
        result += plice_dict[1]
        N -= 1
    elif N >= 0.5:
        result += plice_dict[0.5]
        N -= 0.5
    else:
        result += plice_dict[0.25]
        N -= 0.25

print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
Q, H, S, D = map(int, input().split())  # 0.25, 0.5, 1, 2
H = min(H, 2 * Q)   # 0.5
S = min(S, 2 * H)   # 1
N = int(input())
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())
D=sorted([q*8,h*4,s*2,d])
S=sorted([q*4,h*2,s])
print((N//2)*D[0]+(N-(N//2)*2)*S[0])

Submission status: Accepted

Solution code:
q,h,s,d=map(int,input().split())
N=int(input())
D=[q*8,h*4,s*2,d]
D.sort()
a=D[0]
S=[q*4,h*2,s]
S.sort()
b=S[0]
print((N//2)*a+(N-(N//2)*2)*b)

Submission status: Accepted

Solution code:
P=[int(i) for i in input().split()]
V=[250, 500, 1000, 2000]
N=int(input())*1000

for i in range(1,4):
    P[i] = min(P[i-1]*2,P[i])

ans = 0
for i in range(3,-1,-1):
    ans += N //V[i] *P[i]
    N = N %V[i]

print(ans)

Submission status: Accepted

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

p1 = min(4 * Q, 2 * H, S)
p2 = min(2 * S, D)
print(min([p2 * (N // 2) + p1 * (N % 2), p1 * N]))

Submission status: Accepted

Solution code:
import math

q, h, s, d = [int(i) for i in input().split()]
n = int(input())
size = [0.25, 0.5, 1., 2.]
money = [[0.25 / q, q, 0.25], [0.5 / h, h, 0.5],
         [1 / s, s, 1.], [2 / d, d, 2.]]
# コスパ高い順にソート
money = list(reversed(sorted(money)))
# print(money)
totalMoney = 0
while True:
    totalMoney += int(n / money[0][2]) * money[0][1]
    # print("add:{} {}cup {}yen".format(int(n / money[0][2]) * money[0][1], int(n / money[0][2]), money[0][1]))
    n %= money[0][2]
    # print("totalmoney:{}".format(totalMoney))
    if n == 0:
        print(totalMoney)
        exit()
    del money[0]

"""
leftFlag = True
while True:
    # 確定分のお金を加算
    totalMoney += int(n/money[0][2])*money[0][1]
    print("add:{} {}cup {}yen".format(int(n/money[0][2])*money[0][1], int(n/money[0][2]), money[0][1]))
    n %= money[0][2]
    print("totalmoney:{}".format(totalMoney))
    if n == 0:
        print(totalMoney)
        exit()
    # [お金, どの容器か(q,h,s,d)]
    over = [money[0][1], money[0][2]]
    moreGoodExist = False
    for i in range(1, len(money)):
        if math.ceil(n/money[i][2])*money[i][1] < over[0]:
            over =[math.ceil(n/money[i][2])*money[i][1], money[i][2]]
            moreGoodExist = True
    if moreGoodExist:
        del money[0]
    else:
        print(totalMoney + over[0])
        exit()
"""

Submission status: Accepted

Solution code:
q,h,s,d = map(int, input().split())
N = int(input())
min2 = min(8*q, 4*h, 2*s, d) # 2[l]
min1 = min(4*q, 2*h, s)      # 1[l]
ans = min2*(N//2)
if N%2!=0:
    ans += min1
print(ans)

Submission status: Accepted

Solution code:
q=[int(i) for i in input().split()]
n=int(input())*4
ans=max(q)*n*4
for i in range(4):
    for j in range(4):
        if i==j and i<3:
            ans=min(ans,[q[0]*n,q[1]*n//2,q[2]*n//4][i])
        elif i==j==3 and n%8==0:
            ans=min(ans,q[3]*n//8)
        elif i==3 and n%8 and j<3:
            t=[q[0]*4,q[1]*2,q[2]][j]
            ans=min(ans,q[3]*(n//8)+t)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def inpl(): return [int(i) for i in input().split()]

Q, H, S, D = inpl()
N = int(input())
mini2 = min(8*Q, 4*H, 2*S, D)
mini1 = min(4*Q, 2*H, S)
print(N//2*mini2 + N%2*mini1)

Submission status: Accepted

Solution code:
import sys


def next_str() -> str:
    result = ""
    while True:
        tmp = sys.stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


def next_int() -> int:
    return int(next_str())


def main() -> None:
    q, h, s, d = [next_int() for _ in range(4)]
    n = next_int()
    s = min(4 * q, 2 * h, s)
    
    print(s * (n % 2) + min(2 * s, d) * (n // 2))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
Q,H,S,D = map(int,input().split())
N = int(input())
Q_l = [8*Q,0.25,Q]
H_l = [4*H,0.5,H]
S_l = [2*S,1,S]
D_l = [D,2,D]
L = [Q_l,H_l,S_l,D_l]
L.sort()
cost = 0
for e in L:
    num = int(N // e[1])
    N -= (num) * e[1]
    cost += num * e[2]
print(cost)

Submission status: Accepted

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

Submission status: Accepted

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

q = 4*q
h = 2*h

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

Submission status: Accepted

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

Submission status: Accepted

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

half = min(Q*2,H)
one = min(half*2,S)
doub = min(one*2,D)

ans = (N//2)*doub + (N%2)*one
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,d = map(int,input().split())
n = int(input())
a1 = a*8
b1 = b*4
c1 = c*2
d1 = d
g = n//2
n %= 2
ans = 0
ans += g*(min(a1,b1,c1,d1))
g = n//1
g = int(g)
n = n%1
a1 = a*4
b1 = b*2
c1 = c
ans += g*(min(a1,b1,c1))
g = n//0.5
g = int(g)
n = n%0.5
a1 = a*2
b1 = b*1
ans += g*(min(a1,b1))
g = n//0.25
g = int(g)
n = n%0.25
a1 = a
ans += g*a1
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)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,C,Q = map(int,input().split())
N = int(input())
P = min(4*A,2*B,C)

if N % 2 == 0 :
    ans = min(P*N,Q*N//2)
else :
    ans = min(P*(N-1), Q*(N-1)//2) + P
print(ans)

Submission status: Accepted

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

A = min(4*L[0],2*L[1],L[2])
B = L[3]
if N % 2 == 0 :
    ans = min(A*N,B*N//2)
else :
    ans = min(A*(N-1),B*(N-1)//2) + A
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
n = int(input())
a[0] *= 4
a[1] *= 2
a[3] /= 2
m = min(a)
i = a.index(m)
if i != 3:
    print(n*a[i])
else:
    k = min(a[:-1])
    j = a.index(k)
    print((n//2)*int(2*a[3])+(n%2)*a[j])

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())
m=min(q*4,h*2,s)
M=min(m*2,d)
print((n//2)*M+(n%2)*m)

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 = list(map(int, input().split()))
N = int(input())

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

if N == 1:
	print(x)
elif N == 2:
	print(y)
else:
	if N % 2 == 0:
		print(min(N * x, int(N // 2) * y))
	else:
		print(min(N * x, int(N // 2) * y + x))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b

[q,h,s,d] = getlist()
N = getN()

tanka_ni = min([q*8, h*4, s*2, d])

ans = 0

ans += tanka_ni * (N//2)


if N % 2 == 1:
    ans += min([q*4, h*2, s])

print(ans)

Submission status: Accepted

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

n = int(input())
if n%2==0:
    kosu = n//2
    print(d*kosu)
else:
    kosu = n//2
    print(d*kosu + 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)))