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
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    q,h,s,d = MII()
    n = II()
    print(int((n//2)*min(8*q, 4*h, 2*s, d) + (n%2)*min(4*q, 2*h, s)))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    q,h,s,d = MII()
    n = II()
    pay = [q*4,h*2,s,d/2]
    pay_sorted = sorted(pay)
    min1 = pay_sorted[0]
    min1_index = pay.index(min1)
    min2 = pay_sorted[1]
    min2_index = pay.index(min2)

    if min1_index == 0:
        print(int((n//0.25)*q))
    elif min1_index == 1:
        print(int((n//0.5)*h))
    elif min1_index == 2:
        print(int(n)*s)
    else:
        res = int(n//2)*d
        if n%2 == 1:
            res += pay[min2_index]
        print(res)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
Q, H, S, D = map(int, input().split())
N = int(input())
single = min(Q * 4, H * 2, S)
div, mod = divmod(N, 2)
print(min(single * N, int(D * div) + int(single * mod)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
Q, H, S, D = map(int, input().split())
prices = {0.25: Q, 0.5: H, 1: S, 2: D}
n = int(input())
costs = {0.25: Q * 8, 0.5: H * 4, 1: S * 2, 2: D}
costs_sorted = sorted(costs.items(), key=lambda x: x[1])
ans = 0
for cost in costs_sorted:
    quantity = cost[0]
    div, n = divmod(n, quantity)
    ans += int(prices[quantity] * div)
    if n == 0:
        break

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

res = 0
if 2 * S <= D:
	res = N * S
elif 2 * S > D:
	if N % 2 == 0:
		res = D * (N // 2)
	else:
		res = D * (N // 2) + S

print(res)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

n = int(input())
ans = 0

qqqq = q*4
hh = h*2

best1 = min(qqqq,hh,s)

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

if d >= best1*2:
    print(n*best1)
    exit()


else:
    d_ = n//2
    n -= d_*2
    ans += d*d_
    ans += n*best1
    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(min(s*n, n//2*d + (n%2)*s))

Submission status: Accepted

Solution code:
from itertools import permutations
def main():
    C = list(map( int, input().split()))
    S = [1, 2, 4,8]
    N = 4*int( input())
    ans = 10**20
    for P in permutations( range(4)):
        cost = 0
        left = N
        for i in P:
            cost += left//S[i]*C[i]
            left -= left//S[i]*S[i]
        if cost < ans:
            ans = cost
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a,b,c,d= map(int,input().split())
A=min(min(4*a,2*b),c)
B=min(2*A,d)

n=int(input())
if n %2==0:
    print(n*B//2)
else:
    print((n//2)*B + A)

Submission status: Accepted

Solution code:
A = list(map(int,input().split()))
n = int(input())
base = {}
for i in range(4):
    tmp = 2**(i)
    base.update({i:A[i]/tmp})
dict = sorted(base.items(), key=lambda x: x[1])
m = n*4
ans = 0
for x in dict:
    y = 2**(x[0])
    kosuu = m // y
    m -= y*kosuu
    ans += kosuu*A[x[0]]
print(ans)

Submission status: Accepted

Solution code:
Q, H, S, D = map(int, input().split())
N = int(input())
kouho = []
mv = int(1e9)

if N % 2 == 0:
    for i, j in zip([Q, H, S, D], [0.25, 0.5, 1, 2]):
        kouho.append(int((N // j)*i))
else:
    for i, j in zip([Q, H, S, D], [0.25, 0.5, 1, 2]):
        kouho.append(int((N // j)*i))

    for i, j in zip([Q, H, S], [0.25, 0.5, 1]):
        mv = int(min(i // j, mv))
    kouho[-1] += mv
print(min(kouho))

Submission status: Accepted

Solution code:
from decimal import Decimal as de
q,h,s,d=map(de,input().split())
n=de(input())
ans=0

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

qq = 4 * q
hh = 2 * h
# 1リットルの買い方
one = min(qq, min(hh, s))
# 1リットルずつ買う方が安い
if one < d / 2:
    print(n * one)
else:
    print((n // 2) * d + (n % 2) * one)

Submission status: Accepted

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

q_ef = q*8
h_ef = h*4
s_ef = s*2

if min(q_ef, h_ef, s_ef, d) == d:
    cost += d * (n//2)
    n %= 2

if min(q_ef, h_ef, s_ef) == q_ef:
    cost += q * (n*4)
elif h_ef <= s_ef:
    cost += h * (n*2)
else:
    cost += s * n

print(cost)

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

def readInts():
  return list(map(int,input().split()))
def main():
    q,h,s,d = readInts()
    n = int(input())
    # 2A < B なら 0.25 のみ
    # 2A > B なら　0.5 のみ。
    # "入力は整数であるから、小数点を考える必要がない"
    # よって、0.25 -> 1, 0.5 -> 1 として、かつ1と比較する
    one = min(q*4, h*2, s)
    # そして、1gだけで行けるか、
    # 2gだけで買えるだけ買って、余った分を1gでやる
    print(min(one*n, d*(n//2) + one * (n%2)))#n//2 は 2g ずつなので、 n%2 は1gするか

if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    q, h, s, d = map(int, input().split())
    n = int(input())
    t = min(q * 4, h * 2, s)

    if n == 1:
        print(int(t))
    else:
        if n % 2 == 0:
            print(int(min(t * n, d * n // 2)))
        else:
            print(int(min(t * n, d * ((n - 1) // 2) + t)))


if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

A = [4*a, 2*b, c]
t = 0
if min(A) * 2 > d:
    t = n//2 * d
    n = n - (n//2)*2

t += n * min(A)

print(t)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

q_l, h_l, s_l = q*4, h*2, s
l = min(q_l, h_l, s_l)
q_2l, h_2l, s_2l, d_2l = q*8, h*4, s*2, d
l2 = min(q_2l, h_2l, s_2l, d_2l)

if n % 2 == 0:
    ans = l2 * (n//2)
else:
    ans = l2 * (n//2) + l * 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import deque

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

Q, H, S, D = lr()
N = ir()

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

Submission status: Accepted

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

Submission status: Accepted

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

tmp = [Q*4, H*2, S]
m = min(tmp)

if N == 1:
    print(m)
else:
    print(min(m*2, D) * (N//2) + m*(N%2))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
Q,H,S,D = map(int,input().split())
N = int(input())

ltl_1 = min(4*Q,2*H,S)
lit_2 = min(2*ltl_1,D)
num1 = N%2
num2 = N//2

ans = num2 * lit_2 + num1 * ltl_1
print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

Submission status: Accepted

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

nQ = 4 * Q
nH = 2 * H
nS = S
nD = D / 2

if nD < min(nQ, nH, nS):
    ans = D * (N // 2) + min(nQ, nH, nS) * (N - (N // 2) * 2)
else:
    ans = min(nQ, nH, nS) * N
print(ans)

Submission status: Accepted

Solution code:
def myAnswer(Q: int, H: int, S: int, D: int, N: int) -> int:
    H = min(H, Q*2)
    S = min(S, H*2)
    D = min(D, S*2)
    total = 0
    while N != 0:
        if(N < 2):
            total += S
            N -= 1
        else:
            total += (N//2) * D
            N = N % 2
    return total


def modelAnswer():
    tmp = 1


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
q,h,s,d = map(int,input().split())
lis = [1, 2, 4, 8]
score = [q,h,s,d]
n = int(input())
all_s = 4*n

tmp_li = [8*q,4*h,2*s,d]
tmp_2 = tmp_li[:]
tmp_2.sort()

jun = []
for t in tmp_2:
    jun.append(tmp_li.index(t))
#print('tmp_li',tmp_li,'tmp_2',tmp_2,'jun',jun,'lis',lis)
#[3, 1, 2, 0]

ans = 0
for j in jun:
    a = all_s // lis[j]
    b = all_s % lis[j]
    #print(all_s,a,b,lis[j])
    all_s -= a*lis[j]
    ans += score[j]*a
print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a,b,c,d=map(int, input().split())
n=int(input())
oneltr=min(4*a, 2*b, c, 2*a+b)
twoltr=min(8*a, 4*b, 2*c, d, c+2*b, c+b+2*a,c+4*a,4*a+2*b,b+6*a,3*b+2*a)

if n%2==0 :
               print(twoltr * (n//2))
else :
               print(oneltr+twoltr * ((n-1)//2))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

twoval=min(8*a,4*a+2*b,4*b,2*b+c,2*c,d)
oneval=min(4*a,2*b,2*a+b,c)

if n%2==0:
    print(twoval*(n//2))
else:
    print(oneval+twoval*((n-1)//2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
Q,H,S,D=map(int,input().split())
o=Q*8;h=H*4;s=S*2;d=D
N=int(input())*100
A=[0]*4;p=0;q=N
 
A=[[25,Q,o],[50,H,h],[100,S,s],[200,D,d]]
A.sort(key=lambda x: x[2])
 
#print(A)
 
i=0
while  q>0:
  if q%A[i][0]==0:
    p=p+(q//A[i][0])*A[i][1]
    q=q-(q//A[i][0])*A[i][0]
    break
  else:
    p=p+(q//A[i][0])*A[i][1]
    q=q-(q//A[i][0])*A[i][0]
    i=i+1
 
print(int(p))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

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

    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(int(N//2*A+N%2*B))

Submission status: Accepted

Solution code:
from sys import stdin

q, h, s, d = map(int, stdin.readline().rstrip().split())
n = int(stdin.readline().rstrip())
q *= 4
h *= 2
t = min(q, h, s)
if 2 * t > d:
    print((n // 2) * d + (n % 2) * t)
else:
    print(n * t)

Submission status: Accepted

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

#2Lあたりの金額の最小値
x = min(q * 8, h * 4, s * 2, d)
#1Lあたりの金額の最小値
y = min(q * 4, h * 2, s)

if n == 1:
    print(y)
else:
    if n % 2 == 0:
        print(x * (n // 2))
    else:
        print(x * (n // 2) + y)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
from operator import itemgetter
def main():
    q,h,s,d=map(int,input().split())
    n=int(input())
    weight=[(0.25,q,q/0.25),(0.5,h,h/0.5),(1,s,s),(2,d,d/2)]
    weight.sort(key=itemgetter(2))
    cost=0
    for w in weight:
        kosu=n//w[0]
        cost+=int(w[1]*kosu)
        n-=w[0]*kosu
    print(cost)
if __name__=='__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def main():
    P = list(map(int, input().split()))
    N = int(input())
    p = min(P[0]*4, P[1]*2, P[2])
    print(min(N*p, (N//2)*P[3] + (N%2)*p))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
q, h, s, d = (int(x) for x in input().split())
n = int(input())
l1 = min(4*q, 2*h, s)
l2 = min(8*q, 4*h, 2*s, d)
if n%2 == 0:
  print((n//2) * l2)
else:
  print((n//2) * l2 + l1)

Submission status: Accepted

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

p025 = Q
p05 = min(H, p025 * 2)
p1 = min(S, p05 * 2)
p2 = min(D, p1 * 2)

ans = 0
if N % 2 != 0:
    N -= 1
    ans += p1
ans += (N // 2) * p2

print(ans)

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

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

ans = (N//2)*two_l + (N%2)*one_l
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import heapq
from collections import defaultdict, deque
from math import ceil, factorial
from fractions import gcd
import sys

sys.setrecursionlimit(10 ** 7)
INF = float("inf")
MOD = 10 ** 9 + 7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))


Q, H, S, D = mii()
N = ii()

tea = [
    (Q, 0.25),
    (H, 0.5),
    (S, 1),
    (D, 2),
]
tea.sort(key=lambda x: x[0] / x[1])

ans = 0
remaining = N
for i in range(4):
    p, q = tea[i]
    d, m = map(int, divmod(remaining, q))
    if d == 0:
        continue
    ans += d * p
    remaining = m

print(int(ans))

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
q,h,s,d = iim()
n = ii()

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

Submission status: Accepted

Solution code:
import decimal
a,b,c,d=map(int,input().split())
n=int(input())
l=[a*4,b*2,c,d/2]
p=min(l)
q=min(l[:3])
print(int(decimal.Decimal(n)*decimal.Decimal(min(l))) if n%2==0 or p==q else int(decimal.Decimal(n-1)*decimal.Decimal(d/2)+q))

Submission status: Accepted

Solution code:
Q, H, S, D = map(int, input().split())
N = int(input())
S = min(S, 4*Q, 2*H)
D = min(D, 2*S)
print(D*(N//2) if N % 2 == 0 else D*(N//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)
d=min(d,s*2)
print (d*(n//2)+s*(n%2))

Submission status: Accepted

Solution code:
x = list(map(int, input().split()))
N = int(input())
x[1] = min(x[0] * 2, x[1])
x[2] = min(x[0] * 4, x[1] * 2, x[2])
x[3] = min(x[0] * 8, x[1] * 4, x[2] * 2, x[3])
a = N // 2 * x[3] + (N - 2 * (N // 2)) * x[2]
b = N * x[2]
print(min(a, b))

Submission status: Accepted

Solution code:
import sys
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())

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

l = [(Decimal(0.25), Q, 0.25/Q), (Decimal(0.5), H, 0.5/H), (1, S, 1/S), (2, D, 2/D)]
l.sort(key=lambda x:x[2], reverse=True)
ans = 0
idx = 0
while N != 0:
	n = N//l[idx][0]
	ans += l[idx][1]*n
	N -= l[idx][0]*n

	idx += 1

print(ans)

Submission status: Accepted

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

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

print(n // 2 * two + one if n % 2 else n//2 * two)

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

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

l = [(Decimal(0.25), Q, 0.25/Q), (Decimal(0.5), H, 0.5/H), (1, S, 1/S), (2, D, 2/D)]
l.sort(key=lambda x:x[2], reverse=True)
ans = 0
idx = 0
while N != 0:
	n = N//l[idx][0]
	ans += l[idx][1]*n
	N -= l[idx][0]*n

	idx += 1

print(ans)

Submission status: Accepted

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

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

print((n//2)*min(2*x,d)+(n%2)*x)

Submission status: Accepted

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

cost = N//2

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
q,h,s,d=map(int,input().split())
n=int(input())
 
l=min(q*n*8,h*n*4,s*n*2,d*n)
if l != d*n:
    print (int(l//2))
else:
    m=min(q*4,h*2,s)
    print(int(d*(n-1)//2)+m if n%2==1 else int(l//2))

Submission status: Accepted

Solution code:
q,h,s,d=map(int,input().split())
n=int(input())
 
l=min(q*n*8,h*n*4,s*n*2,d*n)
if l != d*n:
    print(l//2)
else:
    m=min(q*4,h*2,s)
    print((d*(n-1))//2+m if n%2==1 else l//2)

Submission status: Accepted

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

Submission status: Accepted

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

#処理
#0.25を単位として個数に変換
N=N*4
#リットル単価を取得
q=Q*4
h=H*2
s=S
d=D/2
z=[q,h,s,d]
x=[0,0,0,0]
#print(z)
for i in range(4):
    m=max(z)
    j=z.index(m)
    z[j]=0
    x[i]=j
x.reverse()
#print(x)

y=0
for i in x:
    #print(N)
    if i==0:
        t=N
        N=0
        y+=Q*t
    elif i==1:
        t=N//2
        N-=t*2
        y+=H*t
    elif i==2:
        t=N//4
        N-=4*t
        y+=S*t
    else:
        t=N//8
        N-=8*t
        y+=D*t
print(y)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#template
def inputlist(): return [int(j) for j in input().split()]
#template
#issueから始める
Q,H,S,D = inputlist()
N = int(input())
l = min(4*Q,2*H,S)
l2 = min(2*l,D)
d2 = N//2
d1 = (N-d2*2)
print(d2*l2 + d1*l)

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)
res = d*(n//2)
res += s if n%2!=0 else 0
print(res)

Submission status: Accepted

Solution code:
Q,H,S,D = map(int,input().split())
N = int(input())
N *= 100
H = min(H,2*Q)
S = min(S,2*H)
D = min(D,2*S)
ans = 0
if N%200 != N:
  ans += (N//200)*D
  N %= 200
if N%100 != N:
  ans += (N//100)*S
  N %= 100
if N%50 != 50:
  ans += (N//50)*H
  N %= 50
if N%25 != N:
  ans += (N//25)*Q
  N %= 25
if N == 0:
  print(ans)