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:
a,b,c,d = map(int,input().split())
n = int(input())
aval = 4*a
bval = 2*b
cval = c
dval = d/2
if aval == min(aval,bval,cval,dval):
         print(aval*n)
elif bval == min(aval,bval,cval,dval):
         print(bval*n)
elif cval == min(aval,bval,cval,dval):
         print(cval*n)
elif dval == min(aval,bval,cval,dval) and n %2 == 0:
         print(d*(n//2))
else:
         if aval == min(aval,bval,cval):
                  print(d*(n//2) + aval)
         elif bval == min(aval,bval,cval):
                  print(d*(n//2) + bval)
         else:
                  print(d*(n//2) + cval)

Submission status: Accepted

Solution code:
Q, H, S, D = map(int, input().split())
price = { 0.25: Q, 0.5: H, 1.0: S, 2.0: D }
N = int(input())
def f(n, l):
  if l == 0.25:
    return int(n / 0.25) * price[l]
  t = int(n / l)
  return min(f(n - l * t, l / 2) + t * price[l], f(n, l / 2))
print(int(f(N, 2.0)))

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) * int(N%2))

Submission status: Accepted

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

def main():
    Q, H, S, D = map(int, input().split())
    N = int(input())
    c1 = min(Q*4, H*2, S)
    c2 = min(c1*2, D)
    ans = 0
    ans += c2 * (N//2)
    rest = int(N%2)
    ans += c1 * rest
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

print(N % 2 * p1 + N // 2 * p2)

Submission status: Accepted

Solution code:
q,h,s,d = [int(x) for x in input().split()]
n = int(input())
print(min(d,s<<1,h<<2,q<<3)*((n<<2)>>3)+min(s,h<<1,q<<2)*(((n<<2)&((1<<3)-1))>>2)+min(h,q<<1)*(((n<<2)&((1<<2)-1))>>1)+q*((n<<2)&((1<<1)-1)))

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    q,h,s,d = LI()
    d = min(d,2*s,4*h,8*q)
    s = min(s,2*h,4*q)
    h = min(h,2*q)
    n = I()
    n *= 4
    ans = d*(n>>3)
    n &= (1<<3)-1
    ans += s*(n>>2)
    n &= (1<<2)-1
    ans += h*(n>>1)
    n &= (1<<1)-1
    ans += q*n
    print(ans)
    return
#B
def B():

    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    A()

Submission status: Accepted

Solution code:
q = sorted(list(zip(map(int, input().split()), (25, 50, 100, 200))),
           key=lambda a: a[0] / a[1])
n = int(input()) * 100
total = 0
for i in range(len(q)):
    n_buy = (n // q[i][1])
    tmp = n_buy * q[i][1]
    n -= tmp
    total += n_buy * q[i][0]
print(int(total))

Submission status: Accepted

Solution code:
def main():
    Q, H, S, D = map(int, input().split())
    N = int(input())
    N = 4*N
    val = [[Q, Q, 1], [H/2, H, 2], [S/4, S, 4], [D/8, D, 8]]
    val.sort(key = lambda x:x[0])
    ans = 0
    for i in range(4):
        count = N // val[i][2]
        ans += count * val[i][1]
        N = N - count * val[i][2]
    return ans


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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
#AGC014A
import sys
#import collections

#n= int(input())

tmp = input().split()
q,h,s,d = list(map(lambda a: int(a), tmp))

n= int(input())

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

#print(k)
if(2*k<d):
	print(n*k)
else:
	tmp = n%2*k
	print((n-n%2)*d//2+tmp)

Submission status: Accepted

Solution code:
q,h,s,d=map(int,input().split())
#1,2,4,8
n=int(input())*4
a2=min(q*2,h)
a4=min(q*4,h*2,s)
a8=min(q*8,h*4,s*2,d)
a=[0,a2,a4,a8]
ans=0
for i in range(3,0,-1):
    ans+=(n//2**i)*a[i]
    n%=2**i
ans+=n*q
print(ans)

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:
  m = min(4*Q,2*H,S)
  if 2*m <= D:
    print(m*N)
  else:
    print(int(D*(N//2)+m))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


q,h,s,d = LI()
n = I()
a,b,c = q*8,h*4,s*2
x,y = q*4,h*2
if n % 2:
    ans = min(a,b,c,d)*(n//2) + min(x,y,s)
else:
    ans = min(a,b,c,d)*(n//2)
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,d*(N//2)+s*(N%2)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools, collections, copy, heapq


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


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    Q = int(next(tokens))  # type: int
    H = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(Q, H, S, D, N)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

if N % 2 == 0: #偶数Lのとき
    n = N // 2
    print (n * min(8 * Q, 4 * H, 2 * S, D))
else:
    n = N // 2
    print (n * min(8 * Q, 4 * H, 2 * S, D) + min(4 * Q, 2 * H, S))

Submission status: Accepted

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

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

p = [Q,H,S,D]
for i in range(1,4):
    q = [p[i]]
    for j in range(0,i):
        q.append(p[j]*2**(i-j))
    p[i] = min(q)
#print(p)

ans = 0
N *= 4
while N>0:
    if N>=8:
        x = N//8
        ans += p[3]*x
        N-=8*x
    elif N>= 4:
        ans += p[2]
        N-=4
    elif N>= 2:
        ans += p[1]
        N-=2
    else:
        ans += p[0]
        N-=1
print(ans)

Submission status: Accepted

Solution code:
# AGC019A - Ice Tea Store
def main():
    # N is always integer -> choose the best value among 4Q, 2H, S
    Q, H, S, D = list(map(int, input().rstrip().split()))  # 0.25, 0.5, 1, 2
    N = int(input())
    X = min(Q * 4, H * 2, S)
    ans = N // 2 * min(X * 2, D) + N % 2 * X
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
A, B, C, D = [int(_) for _ in input().split()]
N = int(input())

values = [(0.25, A), (0.5, B), (1, C), (2, D)]
values.sort(key=lambda x: x[1] / x[0])

ans = 0
for l, p in values:
    if l > N: continue

    tmp = int(N // l)
    ans += tmp * p
    N -= tmp * l
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c, d = map(int, input().split())
N = int(input())
s = N //2
ans = 0

ans += s * min(a*8, b*4, c*2, d)

if N % 2 == 0:
    pass
else:
    ans += min(a*4, b*2, c)

print(ans)

Submission status: Accepted

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

Q,H,S,D = map(int,input().split())
H = min(H,2*Q) # 1 リットル
S = min(S,2*H) # 2 リットル

N = int(input())
answer = 0
if N&1:
    answer += S
D = min(D,2*S)
answer += (N//2)*D
print(answer)

Submission status: Accepted

Solution code:
# 回答のやつ
# 2019/08/08

Q,H,S,D=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:
# 2019/08/08

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

q=Q*4
h=H*2
s=S
d=D/2
ls=sorted([q,h,s,d])
if ls[0]==d and ls[1]!=d:
    if n%2:
        ans=D*(n//2)+ls[1]
    else:
        ans=D*(n//2)

else:
    ans=int(ls[0]*n)
print(ans)

Submission status: Accepted

Solution code:
# 2Lと1Lを基準にして貪欲
q, h, s, d = map(int, input().split())
n = int(input())
arr = [8 * q, 4 * h, 2 * s, d]
x = min(arr)
if n % 2 == 0:
    print((n // 2) * x)
else:
    ans = (n // 2) * x
    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())

if D%2==1:
    f=1
else:
    f=0

if N//2==0:
    g=1
else:
    g=0

Q*=4
H*=2
S=S
D2=D/2.0
D=D

cnt=0
cost=[[Q,1],[H,1],[S,1],[D2,2]]
cost2=[[Q,1],[H,1],[S,1]]
if min(cost)[1]==2:
    if not(f==1 and g==1):
        cnt+=D*(N//2)
        N%=2

if N!=0:
    cnt+=min(cost2)[0]*N
print(int(cnt))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy

Q, H, S, D = map(int,input().split())
N = int(input())
flat = [8*Q, 4*H, 2*S, D]
work = copy.deepcopy(flat)
work.sort()

rank = 1
order = [0, 0, 0, 0]
for i in range(4):
    for j in range(4):
        if work[i] == flat[j]:
            order[j] = rank
            rank += 1
if order[3] == 1: #2リットルが一番効率がいい
    second = 0
    for i in range(4):
        if order[i] == 2:
            second = i
    if N % 2 == 0:
        print(str(D*N//2))
    else:
        if second == 0:
            print(str(D*(N//2) + Q*4))
        elif second == 1:
            print(str(D*(N//2) + H*2))
        else:
            print(str(D*(N//2) + S))
else:
    buy = 0
    for i in range(4):
        if order[i] == 1:
            buy = i
    if buy == 0:
        print(str(Q*4*N))
    elif buy == 1:
        print(str(H*2*N))
    else:
        print(str(S*N))

Submission status: Accepted

Solution code:
def main():
    q,h,s,d = map(int,input().split())
    n = int(input())
    # one per yen
    one = min([q*4,h*2,s])
    # two per yen
    two = d

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

    else:
        print(n*one)



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from sys import stdin
Q,H,S,D = [int(x) for x in stdin.readline().rstrip().split()]
N = int(stdin.readline().rstrip())

ans = 0
Q4 = Q * 4
H2 = H * 2
D0 = D / 2
QH = Q * 2 + H

if min(Q4,H2,S,D0,QH) == D0:
    ans = ((N // 2) * int(D0 * 2))
    ans += ((N % 2) * min(Q4,H2,S,QH))

else:
    ans = (min(Q4,H2,S,QH) * N)
print(ans)

Submission status: Accepted

Solution code:
from copy import *
from sys import *
import math
import queue
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	p,q,r,s = map(int,input().split())
	n = int(input())
	pickable_1l = min(p*4,q*2,r,p*2+q)
	if(pickable_1l * 2 < s):
		print(n*pickable_1l)
	else:
		print(n//2*s + pickable_1l * (n%2))


def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
Q,H,S,D=map(int,input().split())
digs=sorted([(8*Q,1,Q),(4*H,2,H),(2*S,4,S),(D,8,D)])
N=4*int(input())
ans=0
for _,d,p in digs:
    ans+=p*(N//d)
    N=N%d
print(ans)

Submission status: Accepted

Solution code:
Q,H,S,D=map(int,input().split())
N=4*int(input())
digs=[(1,Q)]
if H<2*Q:
    digs.append((2,H))
if S<4*Q and S<2*H:
    digs.append((4,S))
if D<8*Q and D<4*H and D<2*S:
    digs.append((8,D))
ans=0
for d,p in reversed(digs):
    ans+=p*(N//d)
    N=N%d
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())

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

Submission status: Accepted

Solution code:
from sys import stdin
Q, H, S, D = [int(_) for _ in stdin.readline().rstrip().split()]
N = int(stdin.readline().rstrip())
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())

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

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

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:
q,h,s,d,n=map(int,open(0).read().split())
a=0
if d<min(s*2,h*4,q*8):
  a+=n//2*d
  n%=2
if s<min(h*2,q*4):
  a+=n*s
  n=0
if h<q*2:
  a+=n*2*h
  n=0
print(a+n*4*q)

Submission status: Accepted

Solution code:
cost = list(map(int, input().split()))
size = [1, 2, 4, 8]
N = int(input()) * 4

ans = 0
while N > 0:
    min_ = (N // size[0]) * cost[0]
    q = 0
    for i in range(1,4):
        tmp = (N//size[i]) * cost[i]
        if tmp < min_ and tmp != 0:
            min_ = tmp
            q = i
    ans += min_
    N = N%size[q]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
Q, H, S, D = map(int, input().split()) # 横に2個
N = int(input())

com = [Q*8, H*4, S*2, D]
com.sort()
price = (N // 2) * com[0]

if N % 2 == 1:
    am = [Q*4, H*2, S]
    am.sort()
    price += am[0]

print(price)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

cost = [8*Q, 4*H, 2*S, D]
mult = [4,2,1,1/2]

b = min(cost)
idx = cost.index(b)

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

print(ans)

Submission status: Accepted

Solution code:
cost_list = [ int(v) for v in input().split() ]
size_list = [1,2,4,8]
n = int(input())*4
value_list = list(zip(cost_list,size_list))
value_list = sorted([ [i[0]/i[1]] + list(i) for i in value_list])


ans = 0
for i in value_list:
    a = n // i[2]
    ans += i[1] * a
    n -= a * i[2]
print(ans)

Submission status: Accepted

Solution code:
q, h, s, d = [int(i) for i in input().split()]
n = int(input())
a = [[q*8, 0.25, q], [h*4, 0.5, h], [s*2, 1, s], [d, 2, d]]
a.sort()
if a[0][1] != 2:
    print(int(n/a[0][1]*a[0][2]))
else:
    print(n//2*d+(n%2)*a[1][0]//2)

Submission status: Accepted

Solution code:
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
class UnionFind():

    def __init__(self, n):
        self.n = n
        self.node = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def same(self, x, y):
        return bool(self.root(x) == self.root(y))

    def root(self, x):
        if self.node[x] == x:
            return x
        else:
            self.node[x] = self.root(self.node[x])
            return self.node[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return  # 結合不要
        if self.size[x] < self.size[y]:
            x, y = y, x
        self.node[y] = x
        self.size[x] += self.size[y]

    def return_size(self, x):
        return self.size[self.root(x)]


q, h, s, d = MI()
n = II()
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())

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

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:
Q, H, S, D = map(int, input().split())
N = int(input())

n, cost = N * 4, 0
while 0 < n:
	if 8 <= n:
		offset = n // 8
		cost += (min(D, S * 2, H * 4, Q * 8) * offset)
		n -= (8 * offset)
		continue
	if 4 <= n:
		cost += min(S, H * 2, Q * 4)
		n -= 4
		continue
	if 2 <= n:
		cost += min(H, Q * 2)
		n -= 2
		continue
	if 1 <= n:
		cost += min(Q)
		n -= 1
		continue
print(cost)

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

Submission status: Accepted

Solution code:
Q,H,S,D=[int(i) for i in input().split()]
N=int(input())
Price2 = [Q*8,H*4,S*2,D]
ans = 0
if N==1:
    print(min(Price2[:3])//2)
else:
    Two = N//2
    N %= 2
    print(Two*min(Price2) + N * min(Price2[:3])//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 4*Q < SならQを使ったほうがいいし以下略
q, h, s, d = map(int, input().split())
n = int(input())
x = min(4 * q, 2 * h, s)
if 2 * x <= d:
    ans = n * x
else:
    if n % 2 == 0:
        ans = (n // 2) * d
    else:
        ans = (n // 2) * d + x

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

while N > 0:
    if N == 1:
        ans += min(4*Q, 2*H, S)
        break
    else:
        M = N//2
        ans += min(8*M*Q, 4*M*H, 2*M*S, M*D)
        N -= 2*M

print(ans)

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
Q, H, S, D = map(int, input().split())
N = int(input())
liter_1 = min(4*Q, 2*H, S)
liter_2 = min(2*liter_1, D)
q, r = divmod(N, 2)
ans = q * liter_2 + r * liter_1
print(ans)

Submission status: Accepted

Solution code:
VS = [(Y, Y*(2//q), q) for Y, q in zip(map(int, input().split()), (0.25, 0.5, 1, 2))]
N = int(input())
#print(VS)
tanka = 0
for Y, _, q in sorted(VS, key=lambda x:x[1], reverse=False):
  u = N // q
  N -= q * u
  #print((q, u))
  tanka += Y * int(u)
  if N <= 0:
    break
 
print(tanka)

Submission status: Accepted

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


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

if N % 2 == 0:
    print(two_cost * (N // 2))
else:
    print(two_cost * (N // 2) + one_cost)

Submission status: Accepted

Solution code:
q, h, s, d = [int(item) for item in input().split()]
n = int(input())
smallest1 = min(q*4, h*2, s)
smallest2 = min(smallest1*2, d)

print((n // 2) * smallest2 + (n % 2) * smallest1)

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:
Q, H, S, D = map(int, input().split())
N = int(input())

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

m = 0
m += (N // 2) * D
N = N % 2

m += N * S

print(int(m))

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)+min(q*4,h*2,s)*(n%2))

Submission status: Accepted

Solution code:
import math
Q,H,S,D = [int(x) for x in input().split()]
N = int(input())
H = min(H,Q*2)
S = min(S,H*2)
D = min(D,S*2)
left = N
cost = 0
cost += (left//2)*D
left = left%2
cost += (left//1)*S
print(int(cost))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
A - Ice Tea Store
https://atcoder.jp/contests/agc019/tasks/agc019_a

"""
import sys


def solve(Q, H, S, D, N):
    # 2L単位の最安値で買えるだけ買った後、(もしあれば)端数の1Lを処理する
    q, r = divmod(N, 2)         # 2L単位で購入する場合の必要ユニット数と端数
    d_prices = sorted([Q*8, H*4, S*2, D]) #  2L単位で購入する場合の価格
    ans = q * d_prices[0]
    s_prices = sorted([Q*4, H*2, S]) #  1L単位で購入する場合の価格
    ans += r * s_prices[0]
    return ans


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


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
Q,H,S,D = list(map(int,input().split(" ")))
N = int(input())
min05 = min(Q*2,H)
min1 = min(min05*2 ,S)
min2 = min(min1 * 2 , D)

if N %2 == 0:
    print(N//2 * min2)

else:
    print((N-1)//2 * min2 + min1 )

Submission status: Accepted

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

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

Submission status: Accepted

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

def single():
    return min([S,H*2,Q*4])

def double():
    return min([single()*2,D])

print((N//2)*double()+(N%2)*single())

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

Submission status: Accepted

Solution code:
Q, H, S, D = [int(i) for i in 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 = (int(i) for i in input().split())
N = int(input())

Qper025L = Q
Hper025L = H / 2
Sper025L = S / 4
Dper025L = D / 8

teainfo = [["Q",Qper025L,Q,0.25],["H",Hper025L,H,0.50],["S",Sper025L,S,1],["D",Dper025L,D,2]]

sortedtea = sorted(teainfo, key = lambda x:(x[1],x[2]), reverse = False)

price = 0

for i in range(4):
    if sortedtea[i][3] <= N:
        numbottles = int(N / sortedtea[i][3])
        N -= sortedtea[i][3] * numbottles
        price += sortedtea[i][2] * numbottles

print(int(price))

Submission status: Accepted

Solution code:
from math import ceil,floor
Q,H,S,D=map(int,input().split())
N=int(input())
x=min(4*Q,2*H,S)
if N%2==1:
    print(min(N*x ,floor(N/2)*D + x))
else:
    print(min(N*x ,(N//2)*D))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print((n % 2) * a1 + n // 2 * a2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
q,h,s,d=map(int,input().split())
n=int(input())
q1,h1=q*4,h*2
q2,h2,s2=q*8,h*4,s*2
min1=min(q1,h1,s)
min2=min(q2,h2,s2,d)
mintotal=min(min1*2,min2)
if n%2==0:
  ans=n//2*mintotal
else:
  ans=n//2*mintotal+min1
print(ans)

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)

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
q2 = 8*q
h2 = 4*h
s2 = 2*s
b = min(q2,h2,s2,d)
if n >= 2:
    ans += b*(n//2)
    n = n-2*(n//2)
if n == 0:
    print(ans)
else:
    a = 4*q
    b = 2*q +h
    c = 2*h
    print(ans+min(a,b,c,s))

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

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