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 sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


q,h,s,d = list(map(int, input().split()))
n = int(input())
vals = [q*4, h*2, s, d/2]
v = min(vals)
if v==q*4:
    ans = n*4*q
elif v==h*2:
    ans = n*2*h
elif v==s:
    ans = n*s
else:
    ans = (n//2)*d
    vv = min(vals[:-1])
    if n%2!=0:
        ans += vv
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
(*p, ) = map(int, input().split())
n = int(input())

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

if m == p[3]:
    print(n // 2 * m + n % 2 * m2)
else:
    print(n * m // 2)

Submission status: Accepted

Solution code:
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

Price = list(map(int, input().split()))
Volume = [0.25, 0.5, 1, 2]
Pper = [p/v for (p, v) in zip(Price, Volume)]
N = int(input())

ans = 0
n = Pper.index(min(Pper))
if n != 3:
    ans = int(N/Volume[n]) * Price[n]
else:
    ans = N//2 * Price[3]
    m = Pper.index(min(Pper[:3]))
    nokori = N % 2
    ans += int(nokori/Volume[m]) * Price[m]

print(ans)

Submission status: Accepted

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

ans = 0

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

if s*2 <= d:
    ans = s*n
elif s*2 > d:
    ans = n//2*d + n%2*s

print(ans)

Submission status: Accepted

Solution code:
s = list(map(int, input().split()))
n = int(input()) * 100
ss = [s[0] * 4, s[1] * 2, s[2], s[3] // 2]
ll = [25, 50, 100, 200]
cost = 0
while n > 0:
    if n >= 200:
        pass
    elif n >= 100:
        ss = ss[:3]
        ll = ll[:3]
    elif n >= 50:
        ss = ss[:2]
        ll = ll[:2]
    else:
        ss = ss[:1]
        ll = ll[:1]
    ssm = ss.index(min(ss))
    cnt = n // ll[ssm]
    cost += s[ssm] * cnt
    n -= ll[ssm] * cnt
print(cost)

Submission status: Accepted

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

print(min(n*min_1l, (n//2)*min_2l + (n%2)*min_1l))

Submission status: Accepted

Solution code:
Q, H, S, D = map(int, input().split())
N = int(input()) * 4
L = [[8*Q, 1, Q], [4*H, 2, H], [2*S, 4, S], [D, 8, D]]
L.sort()
ans = 0
for l in L:
  s, t = N // l[1], N % l[1]
  ans += s * l[2]
  N = t
print(ans)

Submission status: Accepted

Solution code:
from math import inf

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

L=inf
M=inf
for a in range(8+1):
    for b in range(4+1):
        for c in range(2+1):
            for d in range(1+1):
                if a+2*b+4*c+8*d==8:
                    L=min(L,a*Q+b*H+c*S+d*D)
                    
            if a+2*b+4*c==4:
                M=min(M,a*Q+b*H+c*S)

if N%2:
    print(L*(N//2)+M)
else:
    print(L*(N//2))

Submission status: Accepted

Solution code:
def main():
    q, h, s, d = map(int, input().split())
    n = int(input())
    min_1 = min(q*4, h*2, q*2+h, s)
    min_2 = min(min_1*2, d)

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    q, h, s, d = map(int, input().split())
    n = int(input())
    min_1 = min(q*4, h*2, q*2+h, s)
    min_2 = min(min_1*2, d)

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

Q,H,S,D = I()
N = i()

a = N // 2
b = N // 1
c = N // 0.5
d = N // 0.25

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
price = [int(x) for x in input().split()];
N = int(input());
price_d = price[3];
price_s = 2*price[2];
price_h = 4*price[1];
price_q = 8*price[0];
p = min([price_q,price_h,price_s]);
if price_d < p :
    if N%2 == 1 :
        ans = (N-1)//2*price_d + p//2;
    else :
        ans = N//2*price_d;
else :
    ans = N*p//2;

print(ans);

Submission status: Accepted

Solution code:
Q,H,S,D=list(map(int,input().split()))
N=int(input())
ans=(N//2)*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,re,d = map(int,input().split())
n = int(input())
re = min(q*4, h*2,re)
print(min(re*n, n//2*d + (n%2)*re))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a, b, c, d = map(int, input().split())
n = int(input())
 
b = min(a + a, b)
c = min(b + b, c)
d = min(c + c, d)
 
q, r = divmod(n, 2)
x = q * d + r * c
print(x)

Submission status: Accepted

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

# Q,H を 1Lあたりの費用に変換する

Q *= 4
H *= 2

one_litter = min(Q, H, S)  # 1L はこれを使う

if 2 * one_litter < D:  # 2Lをサイズのほうが高いときは1Lですべて買う
    ans = N * one_litter
else:  # 偶数を2Lサイズで買い、余りを1Lサイズで買う
    ans = N // 2 * D + (N % 2) * one_litter

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
Q,H,S,D = map(int, input().split())
N = int(input())
if N >=2:
    if N%2 == 0:
        ans = N//2*min([8*Q,4*H,2*S,D])
    else:
        ans = (N-1)//2*min([8*Q,4*H,2*S,D]) + min([4*Q,2*H,S])
else:
    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())
litre=min(4*Q,2*H,S)
Litre=min(2*litre,D)
if N%2==0:
  print(Litre*(N//2))
else:
  print(Litre*(N//2)+litre)

Submission status: Accepted

Solution code:
Q,H,S,D=map(int,input().split())
N=int(input())
N2,N1=divmod(N,2)
tmp2=min(8*Q,4*H,2*S,D)
tmp1=min(4*Q,2*H,S)
ans2=N2*tmp2
ans1=N1*tmp1
ans=ans1+ans2
print(ans)

Submission status: Accepted

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

L=min(4*Q, 2*H,S)
if 2*L<=D:
    ans=N*L
else:
    m=N//2
    ans=m*D+L*(N-2*m)
    
print(ans)

Submission status: Accepted

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

    ls = [[0.25, Q, 8*Q, 0], [0.5, H, 4*H, 0], [1, S, 2*S, 0], [2, D, D, 0]]
    ls.sort(key=lambda x: x[2])

    for i in range(4):
        if N < ls[i][0]:
            continue

        ls[i][3] += int(N // ls[i][0])
        N -= ls[i][0] * ls[i][3]

        ans += ls[i][1] * ls[i][3]

    ans = int(ans)
    print(ans)
    return


resolve()

Submission status: Accepted

Solution code:
from collections import defaultdict
import bisect

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

q,h,s,d = readInts()
n = readInt()

reasonable = [-1,-1]
value = {"0.25":q,"0.5":h,"1":s,"2":d}
t = min(8*q,4*h,2*s,d)
if t==8*q:
  reasonable = [0.25,q]
  ans = (n//reasonable[0])*reasonable[1]
  print(int(ans))
elif t==4*h:
  reasonable = [0.5,h]
  ans = (n//reasonable[0])*reasonable[1]
  print(int(ans))
elif t==2*s:
  reasonable = [1,s]
  ans = (n//reasonable[0])*reasonable[1]
  print(ans)
else:
  reasonable = [2,d]
  remain = n%2
  money = 0
  if remain==1:
    money = min(4*q,2*h,1*s)
  print(int(money)+(n//reasonable[0])*reasonable[1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
q, h, s, d = [int(i) for i in input().split()]
n = int(input())
d = min(min(d, s*2), min(h*4, q*8))
s = min(s, min(h*2, q*4))
h = min(h, q*2)
ans = (n // 2) * d
n %= 2
while n > 0:
    if n >= 1:
        n -= 1
        ans += s
    elif n >= 0.5:
        n -= 0.5
        ans += h
    else:
        n -= 0.25
        ans += q

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

l = min(4*q, 2*h, s)
l_2 = min(2*l, d)

print((n//2) * l_2 + (n%2) * l)

Submission status: Accepted

Solution code:
def resolve():
    # import sys
    # input = sys.stdin.readline
    Q, H, S, D = [int(i) for i in input().split()]
    N = int(input())
    a = []
    a.append(N * S)
    a.append(N * H * 2)
    a.append(N * Q * 4)
    if N > 1:
        if N % 2 == 0:
            a.append((N // 2) * D)
        else:
            a.append((N // 2) * D + S)
            a.append((N // 2) * D + H * 2)
            a.append((N // 2) * D + Q * 4)
    print(min(a))


resolve()

Submission status: Accepted

Solution code:
Q, H, S, D = map(int, input().split())
N = int(input())
a = N // 2
b = N % 2

money = a * min(8*Q, 4*H, 2*S, D) \
        + b * min(4*Q, 2*H, S)

print(money)

Submission status: Accepted

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

Submission status: Accepted

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

b = min(a + a, b)
c = min(b + b, c)
d = min(c + c, d)

q, r = divmod(N, 2)
x = q * d + r * c
print(x)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a, b, c, d, N = map(int, read().split())

b = min(a + a, b)
c = min(b + b, c)
d = min(c + c, d)

q, r = divmod(N, 2)
x = q * d + r * c
print(x)

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) + (N % 2) * min(Q*4, H*2, S)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
y=list(map(int, input().split()))
N=int(input())
ans=0

if N>=2:
  tmp=min(y[0]*8, y[1]*4, y[2]*2, y[3])
  rep=N//2
  ans+=rep*tmp
  N-=rep*2

if N==1:
  ans+=min(y[0]*4, y[1]*2, y[2])

print(ans)

Submission status: Accepted

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

if N % 2 == 0:
  print(min(M * 2 * N, S * N, D * N // 2))
else:
  print(min((M * 2 * (N-1)) + M * 2, S * (N-1) + S, D * (N-1) // 2 + M * 2, D * (N-1) // 2 + S))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
def main():
    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)

    cost = [
        [0.25, Q],
        [0.5, H],
        [1, S],
        [2, D]
    ]

    cost.sort(reverse = True, key = lambda x : x[0])

    ans = 0
    for c in cost:
        if N <= 0:
            break

        r, m = divmod(N, c[0])
        ans += r*c[1]
        N -= r*c[0]

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

Q,H,S,D = I()
N = i()
A = [[Q*8,0.25,Q],[H*4,0.5,H],[S*2,1,S],[D,2,D]]
A.sort()
ans = 0
for i in range(4):
    a,b,c = A.pop(0)
    if b <= N:
        ans += int((N//b)*c)
        N -= (N//b)*b
    if N == 0:
        print(ans)
        break

Submission status: Accepted

Solution code:
Q, H, S, D = map(int, input().split())
N = int(input())*4
arr = [[Q, Q, 1], [H/2, H, 2], [S/4, S, 4], [D/8, D, 8]]
arr.sort()
ans = 0
for _, cost, size in arr:
    ans += (N//size)*cost
    N %= size
    if N == 0: break
print(ans)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

Q, H, S, D = MAP()
N = INT()

ans1 = 4*Q*N
ans2 = 2*H*N
ans3 = S*N
ans4 = D*(N//2) + min(4*Q, 2*H, S)*(N%2)

print(min(ans1, ans2, ans3, ans4))

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

Q, H, S, D = MAP()
N = INT()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

l = min(Q*4, H*2, S)
ll = min(l*2, D)
res = N//2*ll
if N % 2 == 1:
    res += l

print(res)

Submission status: Accepted

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

# 1L
cost_per_1L=min(q*4, h*2, s)
# 2L
cost_per_2L=min(cost_per_1L*2, d)

q,r = divmod(n, 2)

print(cost_per_2L*q + cost_per_1L*r)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
t=list(map(int,input().split()))
s=[t[i]*(2**(3-i)) for i in range(4)]
n=int(input())
p,d=divmod(n,2)
print(p*min(s)+d*min([i//2 for i in s[:3]]))

Submission status: Accepted

Solution code:
ans=0
q,h,s,d=map(int,input().split())
n=int(input())
l=[(q,q*8,0.25),(h,h*4,0.5),(s,s*2,1),(d,d,2)]
l.sort(key=lambda x:-x[1])
while n>0:
    c=l.pop()
    ans+=c[0]*int(n//c[2])
    n-=c[2]*int(n//c[2])
    
print(ans)

Submission status: Accepted

Solution code:
sizePrice = list(map(int, input().split()))
N = int(input())
oneLMin = min([sizePrice[0] * 4, sizePrice[1] * 2, sizePrice[2]])
twoLMin = min([oneLMin*2, sizePrice[3]])
ans = 0
if N % 2 == 0:
    ans = twoLMin * (N//2)
else:
    ans = twoLMin * ((N - 1)//2) + oneLMin
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)
L1 = min(S,2*H,4*Q)

ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

a = min(A[0]*4, A[1]*2, A[2])
b = A[3]

ans = min(N * a, N//2*b + (N%2)*a)
print(ans)

Submission status: Accepted

Solution code:
q, h, s, d = [int(x) for x in input().split()]
n = int(input())
per_l = min(4 * q, 2 * h, s)   # 1L買うのに一番安い方法
per_2l = min(2 * per_l, d) # 2Lを買うのに一番安い方法

print(per_2l * (n // 2) + per_l * (n % 2))

Submission status: Accepted

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

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

yen = 0

yen += (n//2)*d
yen += (n%2)*s

print(yen)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

Q, H, S, D = MAP()
N = INT()

ans1 = 4*Q*N
ans2 = 2*H*N
ans3 = S*N
ans4 = D*(N//2) + min(4*Q, 2*H, S)*(N%2)

print(min(ans1, ans2, ans3, ans4))

Submission status: Accepted

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    Q, H, S, D = map(int, input().split())
    N = int(input())
    Double = [Q * 8, H * 4, S * 2, D]
    Single = [Q * 4, H * 2, S]
    if N % 2 == 0: print(min(Double) * N // 2)
    else: print(min(Double) * (N - 1) // 2 + min(Single))

    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
 
q,h,s,d=map(int,input().split())
n=int(input())

a=min(d,s*2,h*4,q*8) #2L
b=min(s,h*2,q*4) #1L
ans=0
ans+=(n//2)*a
n-=2*(n//2)
ans+=n*b
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    q,h,s,d=map(int,readline().split())
    n=int(readline())

    if n%2==0:
        print(min(4*q*n,2*h*n,s*n,d*n//2))
    else:
        tmp1=min(4*q*(n-1),2*h*(n-1),s*(n-1),d*(n-1)//2)
        tmp2=min(4*q,2*h,s)
        print(tmp1+tmp2)
        
if __name__=="__main__":
    main()

Submission status: Accepted

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

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(2 * S, D) + N % 2 * S)

Submission status: Accepted

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())
Q, R = divmod(n, 2)
ans = Q*min([8*q, 4*h, 2*s, d]) + R*min([4*q, 2*h, s])
print(ans)

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
from collections import defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
q,h,s,d = readInts()
n = I()
#4*q, 2*h, s, d - 2
Q = 4*q;H = 2*h
print(min(d * (n//2) + n%2 * min(Q,H,s), min(Q,H,s)*n))

Submission status: Accepted

Solution code:
Q,H,S,D = map(int,input().split())
N = int(input())
a2 = min(Q*8,H*4,S*2,D)
ans = (N//2)*a2
a1 = min(Q*4,H*2,S)
ans += (N%2)*a1
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:
Q,H,S,D = map(int,input().split())
N = int(input())

a = (N//2)*D + (N%2)*min(4*Q,2*H,S)
b = N*S
c = H*2*N
d = Q*4*N

print(min(a,b,c,d))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
q,h,s,d = map(int,input().split())
#20 30 70 90
N = int(input())
#3


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

if o*2 <= d:
	print(o*N)
else:
	print(d*(N//2) + o*(N%2))

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
Q,H,S,D = IL()
N = I()

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

Submission status: Accepted

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

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

Q, H, S, D, N = map(int, read().split())
H = min(Q * 2, H)
S = min(H *2 , S)

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

Submission status: Accepted

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

cost = [Q, min(Q*2, H), min(Q*4, H*2, S), min(Q*8, H*4, S*2, D)]

print(N//2*cost[3] + N%2*cost[2])

Submission status: Accepted

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

#1リットル買う最も安い方法を考える
x = a*4
y = b*2
z = min(x,y,c)
if z == x:
    e = x
elif z == y:
    e = y
else:
    e = c

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

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

Submission status: Accepted

Solution code:

#q:0.25,h:0.5,s:1,d:2
#q,h,s,d=
cost=list(map(int,input().split()))

one=min(cost[0]*4,cost[1]*2,cost[2])

n=int(input())

if n==1:
    print(one)
    exit()

if n%2==0:
    print(n//2*min(one*2,cost[3]))
else:
    print(n//2*min(one*2,cost[3])+one)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    Q, H, S, D = [int(x) for x in input().split()]
    N = int(input())

    ans = 0
    if Q * 8 > D and H * 4 > D and S * 2 > D:
        X, N = divmod(N, 2)
        ans += X * D

    if Q * 4 > S and H * 2 > S:
        print(ans + S * N)
    elif Q * 2 > H:
        print(ans + H * 2 * N)
    else:
        print(ans + Q * 4 * N)


    
    

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
q,h,s,d=map(int,input().split())
n=int(input())
a1=min(8*q,4*h,2*s,d)#2Lあたりの一番安い金額
a2=min(4*q,2*h,s)#1Lあたりの一番安い金額
if n%2==0:
    ans=(n//2)*a1
else:
    ans=(n//2)*a1+a2
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(N*S)
else:
    if N%2==0:
        print((N//2)*D)
    else :
        print((N//2)*D+S)