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: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
price=list(map(int,input().split()))
k=[0.25,0.5,1.0,2.0]

N=int(input())

from itertools import permutations
ans=float("Inf")
for x in permutations([0,1,2,3]):
  tmp=0
  n=N
  for y in x:
    tmp+= (n//k[y])*price[y]
    n=n%k[y]
  ans=min(tmp,ans)
  
print(int(ans))

Submission status: Wrong Answer

Solution code:
ps = []
l = 0.25
for p in map(int,input().split()):
  ps.append([p/l, l, p])
  l *= 2
ps.sort()

n = int(input())
ans = 0
for unitp, l, p in ps:
  num = n//l
  ans += num*p
  n -= int(num*l)
print(int(ans))

Submission status: Wrong Answer

Solution code:
ps = []
l = 0.25
for p in map(int,input().split()):
  ps.append([p/l, p, l])
  l *= 2
ps.sort()

n = int(input())
ans = 0
for unitp, p, l in ps:
  num = n//l
  ans += num*p
  n -= int(num*l)
print(int(ans))

Submission status: Wrong Answer

Solution code:
ps = []
factor = 8
l = 0.25
for p in map(int,input().split()):
  ps.append([p*factor, p, l])
  factor //= 2
  l *= 2
ps.sort()

n = int(input())
ans = 0
for unitp, p, l in ps:
  num = n//l
  ans += num*p
  n -= num*l

print(int(ans))

Submission status: Wrong Answer

Solution code:
ps = []
l = 8
for p in map(int,input().split()):
  ps.append([p*l, p, l])
  l //= 2
ps.sort()

n = int(input())
ans = 0
for unitp, p, l in ps:
  num = n//l
  ans += num*p
  n -= num*l

print(int(ans))

Submission status: Wrong Answer

Solution code:
ps = []
l = 0.25
for p in map(int,input().split()):
  ps.append([p/l, p, l])
  l *= 2
ps.sort()

n = int(input())
ans = 0
for unitp, p, l in ps:
  num = n//l
  ans += num*p
  n -= num*l
print(int(ans))

Submission status: Wrong Answer

Solution code:
def f(num):
        if num == 2:
                return 8
        elif num == 1:
                return 4
        elif num == 0.5:
                return 2
        elif num == 0.25:
                return 1

from operator import itemgetter
import math
q, h, s, d = map(int, input().split())
n = int(input())

_h = h/2
_s = s/4
_d = d/8

l = [[0.25, q], [0.5, _h], [1, _s], [2, _d]]

l.sort(key=itemgetter(1))
minPrice = l[0][1]
minNum = l[0][0]
minPrice2 = l[1][1]
minNum2 = l[1][0]

# print(minPrice)
# print(minNum)
# print(minPrice2)
# print(minNum2)

ans = 0
# print("---")
if minNum != 2:
        # print("min単価がD以外")#OK
        ans = minPrice * f(minNum) * (n / minNum)
else:
        # print("min単価がD")
        if n < 2:
                # print("n<2")#OK
                ans = minPrice2 * f(minNum2) * (n / minNum2)
        else:
                if n%2 == 0:
                        # print("n>=2 nが偶数")#OK
                        ans = minPrice * f(minNum) * (n / minNum)
                else:
                        # print("n>=2 nが奇数")#OK
                        ans = (minPrice * f(minNum) * ((n-1) / minNum)) + minPrice2 * f(minNum2) * (1 / minNum2)
print(math.ceil(ans))

Submission status: Wrong Answer

Solution code:
def f(num):
        if num == 2:
                return 8
        elif num == 1:
                return 4
        elif num == 0.5:
                return 2
        elif num == 0.25:
                return 1

from operator import itemgetter
q, h, s, d = map(int, input().split())
n = int(input())

_h = h/2
_s = s/4
_d = d/8

l = [[0.25, q], [0.5, _h], [1, _s], [2, _d]]

l.sort(key=itemgetter(1))
minPrice = l[0][1]
minNum = l[0][0]
minPrice2 = l[1][1]
minNum2 = l[1][0]

# print(minPrice)
# print(minNum)
# print(minPrice2)
# print(minNum2)

ans = 0
# print("---")
if minNum != 2:
        # print("min単価がD以外")#OK
        ans = minPrice * f(minNum) * (n / minNum)
else:
        # print("min単価がD")
        if n < 2:
                # print("n<2")#OK
                ans = minPrice2 * f(minNum2) * (n / minNum2)
        else:
                if n%2 == 0:
                        # print("n>=2 nが偶数")#OK
                        ans = minPrice * f(minNum) * (n / minNum)
                else:
                        # print("n>=2 nが奇数")#OK
                        ans = (minPrice * f(minNum) * ((n-1) / minNum)) + minPrice2 * f(minNum2) * (1 / minNum2)
print(int(ans))

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

q, h, s, d = ril()
n = ri()
x = min(4 * q, 2 * h, s)
if 2 * x < d:
    print(n * x)
else:
    print(n // 2 * d + x)

Submission status: Wrong Answer

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

dic = {0.25:q*4, 0.5:h*2, 1:s, 2:d/2}
dic_sorted = sorted(dic.items(),key=lambda x:x[1])

temp1 = n//dic_sorted[0][0]
temp2 = n%dic_sorted[0][0]

cnt = temp2
ans = temp1 * dic_sorted[0][1] * dic_sorted[0][0]

while cnt != 0:
    for i in range(4):
        if dic_sorted[i][0] <= cnt:
            cnt -= dic_sorted[i][0]
            ans += dic_sorted[i][1] * dic_sorted[i][0]
            break
            
print(int(ans))

Submission status: Wrong Answer

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

dic = {0.25:q*4, 0.5:h*2, 1:s, 2:d/2}
dic_sorted = sorted(dic.items(),key=lambda x:x[1])

temp1 = n//dic_sorted[0][0]
temp2 = n%dic_sorted[0][0]

cnt = temp2
ans = temp1 * dic_sorted[0][1]

while cnt != 0:
    for i in range(4):
        if dic_sorted[i][0] <= cnt:
            cnt -= dic_sorted[i][0]
            ans += dic_sorted[i][1] * dic_sorted[i][0]
            break
            
print(int(ans))

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
q,h,s,d = map(int,input().split())
n = int(input())
lst = [[q/0.25,q,0.25,q],[h/0.5,h,0.5,h],[s,s,1.0,s],[d/2,d,2.0,d]]
lst.sort()
lst = sorted(lst, key=lambda x:(x[0], x[1]))
now = 0
money = 0
s = 0
while s < n:
  money += lst[now][3]*((n-s)//lst[now][2])
  s += ((n-s)//lst[now][2])*lst[now][2]
  now += 1
print(int(money))

Submission status: Wrong Answer

Solution code:
q,h,s,d = map(int,input().split())
n = int(input())
lst = [[q/0.25,0.25,q],[h/0.5,0.5,h],[s,1.0,s],[d/2,2.0,d]]
lst.sort()
now = 0
money = 0
s = 0
while s < n:
  money += lst[now][2]*((n-s)//lst[now][1])
  s += ((n-s)//lst[now][1])*lst[now][1]
  now += 1
print(int(money))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
Q,H,S,D=map(int,input().split())
N=int(input())
temp=min(4*Q,2*H,S,D/2)

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
Q,H,S,D=map(int,input().split())
N=int(input())
temp=min(4*Q,2*H,S,D/2)

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
Q,H,S,D=map(int,input().split())
N=int(input())
temp=min(4*Q,2*H,S,D/2)

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
Q,H,S,D=map(int,input().split())
N=int(input())
temp=min(4*Q,2*H,S,D//2)

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

Submission status: Wrong Answer

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

if n % 2 == 0:
    l = [4*q*n, 2*h*n, s*n, d*n/2]
    l.sort()
    print(int(l[0]))
else:
    l = [4*q*(n-1), 2*h*(n-1), s*(n-1), d*(n-1)/2]
    l_rest =  [4*q, 2*h, s]
    l.sort()
    l_rest.sort()
    print(int(l[0]+l_rest[0]))

Submission status: Wrong Answer

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

per_cost = [4*q, 2*h, s, d/2]
per_amount = [0.25, 0.5, 1, 2]
l = list(zip(per_cost, per_amount))
l.sort()

cost = 0
for e in l:
    if n >= e[1]:
        cost += n // e[1] * (e[0]*e[1])
        n %= e[1]
    if n == 0:
        break

print(int(cost))

Submission status: Wrong Answer

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

per_cost = [4*q, 2*h, s, d/2]
per_amount = [0.25, 0.5, 1, 2]
l = list(zip(per_cost, per_amount))
l.sort()

cost = 0
for e in l:
    cost += n // e[1] * (e[0]*e[1])
    n %= e[1]
    if n == 0:
        break

print(int(cost))

Submission status: Wrong Answer

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

array = [[Q*8, Q, 0.25], [H*4, H, 0.5], [S*2, S, 1], [D, D, 2]]

array.sort()

total = 0
for i in range(4):
    total += N // array[i][2] * array[i][1]
    N %= array[i][2]
    
print(int(total))

Submission status: Wrong Answer

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

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

if n == 1:
    print(int(min(Q, H, S)))
else:
    if min(Q, H, S) <= D:
        print(int(n * min(Q, H, S)))
    else:
        x, y = divmod(n, 2)
        print(int(x * 2 * D + y * min(Q, H, S)))

Submission status: Wrong Answer

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

Q = q / 0.25
H = h / 0.5
S = s
D = d / 2.0

if n == 1:
    print(int(min(Q, H, S)))
else:
    if min(Q, H, S) <= D:
        print(int(n * min(Q, H, S)))
    else:
        x, y = divmod(n, 2)
        print(int(x * 2 * D + y * min(Q, H, S)))

Submission status: Wrong Answer

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

Q = q / 0.25
H = h / 0.5
S = s
D = d / 2.0

if n == 1:
    print(min(Q, H, S))
else:
    if min(Q, H, S) <= D:
        print(n * min(Q, H, S))
    else:
        x, y = divmod(n, 2)
        print(x * 2 * D + y * min(Q, H, S))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

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

def main():
  q,h,s,d=LI()
  n=I()

  l=[]
  l.append([0.25,q,q*4])
  l.append([0.5,h,h*2])
  l.append([1,s,s])
  l.append([2,d,d/2])

  l=sorted(l,key=lambda x:x[2])

  ans=0
  if l[0][0]==2:
    if n%2!=0:
      ans+=(n//2)*l[0][1]
      n%=2
      ans+=(n//l[1][0])*l[1][1]
      return int(ans)
    else:
      return int((n//2)*l[0][1])
  else:
    return int((n//l[0][0])*l[0][1])

# main()
print(main())

Submission status: Wrong Answer

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

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

k=[0.25, 0.5, 1, 2]
ans=0
for i in range(4)[::-1]:
	ans += (N//k[i])*A[i]
	N-=k[i]*(N//k[i])

print(int(ans))

Submission status: Wrong Answer

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

l = min(Q, H, S)
price = N * l

if N >= 2 and 2*l > D:
    n = N // 2
    price = D * n + l * n

print(price)

Submission status: Wrong Answer

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

C=[[0]*3 for _ in range(4)]
C[0]=[0.25,Q,4*Q]
C[1]=[0.5,H,2*H]
C[2]=[1,S,S]
C[3]=[2,D,D/2]

C.sort(key=lambda x:x[2])

if C[0][0]==2 and N%2!=0:
    ans=N//2*D+C[1][2]
else:
    ans=N*C[0][2]

print(int(ans))

Submission status: Wrong Answer

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

C=[[0]*3 for _ in range(4)]
C[0]=[0.25,Q,Q/0.25]
C[1]=[0.5,H,H/0.5]
C[2]=[1,S,S]
C[3]=[2,D,D/2]

C.sort(key=lambda x:x[2])

if C[0][0]==2 and N%2!=0:
    ans=(N-1)*C[0][2]+C[1][2]
else:
    ans=N*C[0][2]

print(int(ans))

Submission status: Wrong Answer

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

C=[[0]*3 for _ in range(4)]
C[0]=[0.25,Q,Q/0.25]
C[1]=[0.5,H,H/0.5]
C[2]=[1,S,S]
C[3]=[2,D,D/2]

C.sort(key=lambda x:x[2])

if C[0][0]==2 and N%2!=0:
    ans=(N-1)//C[0][0]*C[0][1]+1//C[1][0]*C[1][1]
else:
    ans=N//C[0][0]*C[0][1]

print(int(ans))

Submission status: Wrong Answer

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

C=[[0]*3 for _ in range(4)]
C[0]=[0.25,Q,8*Q]
C[1]=[0.5,H,4*H]
C[2]=[1,S,2*S]
C[3]=[2,D,D]

C.sort(key=lambda x:x[2])

if C[0][0]==2 and N==1:
    ans=N//C[1][0]*C[1][1]
elif C[0][0]==2 and N%2!=0:
    ans=(N-1)//C[0][0]*C[0][1]+1//C[1][0]*C[1][1]
else:
    ans=N//C[0][0]*C[0][1]

print(int(ans))

Submission status: Wrong Answer

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

C=[[0]*3 for _ in range(4)]
C[0]=[0.25,Q,8*Q]
C[1]=[0.5,H,4*H]
C[2]=[1,S,2*S]
C[3]=[2,D,D]

C.sort(key=lambda x:x[2])

if C[0][0]==2 and N%2!=0:
    ans=(N-1)//C[0][0]*C[0][1]+1//C[1][0]*C[1][1]
else:
    ans=N//C[0][0]*C[0][1]

print(int(ans))

Submission status: Wrong Answer

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 (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: Wrong Answer

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

p = [
    [0.25, 4*Q, Q ],
    [0.50, 2*H, H ],
    [1, S, S],
    [2, D/2, D],
    ]
p.sort(key=lambda x: x[1])
price = 0
for s in p:
    if N // s[0] > 0:
        price += N//s[0] * s[2]
        N = N % s[0]

print('{:.20g}'.format(price))

Submission status: Wrong Answer

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

p = [
    [0.25, 4*Q, Q ],
    [0.50, 2*H, H ],
    [1, S, S],
    [2, D/2, D],
    ]
p.sort(key=lambda x: x[1])
price = 0
for s in p:
    if N // s[0] > 0:
        price += N//s[0] * s[2]
        N = N % s[0]

print(round(price))

Submission status: Wrong Answer

Solution code:
q,h,s,d = [int(x) for x in input().split()]
n = int(input())
print(min(d,s<<1,h<<2,q<<8)*((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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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/2)*N+m))

Submission status: Wrong Answer

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((D/2)*N+m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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)
    else:
        ans=D*(n//2)+ls[1]

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

Submission status: Wrong Answer

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 n%2 and ls[0]==d and ls[1]!=d:
        ans=(ls[0]*2)*(n//2)+ls[1]
else:
    ans=ls[0]*n
print(ans)

Submission status: Wrong Answer

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)
ans = (n // 2) * x

if n / 2 > 0:
    ans += min([4 * q, 2 * h, s])
print(ans)

Submission status: Wrong Answer

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)
ans = (n // 2) * x
print(x, ans)
if n / 2 > 0:
    ans += min([4 * q, 2 * h, s])
print(ans)

Submission status: Wrong Answer

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
D/=2.0

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

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

Submission status: Wrong Answer

Solution code:
q,h,s,d = map(float,input().split())
n = int(input())
k = [
    [q*8,q,0.25],
    [h*4,h,0.5],
    [s*2,s,1],
    [d,d,2]
    ]
k.sort() #単価の安い順にする．
cost = 0
for i in range(4):
    num = (n // k[i][2]) * k[i][1]
    cost += num
    n %= k[i][2]
print(int(cost))

Submission status: Wrong Answer

Solution code:
q,h,s,d = map(int,input().split())
n = int(input())
k = [
    [q*8,q,0.25],
    [h*4,h,0.5],
    [s*2,s,1],
    [d,d,2]
    ]
k.sort() #単価の安い順にする．
cost = 0
for i in range(4):
    num = (n // k[i][2]) * k[i][1]
    cost += num
    n %= k[i][2]
print(int(cost))

Submission status: Wrong Answer

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 = min([2*one,d])

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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: Wrong Answer

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

Submission status: Wrong Answer

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//2)*min(cperl)))

Submission status: Wrong Answer

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//2*min(cperl)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

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

print(ans)

Submission status: Wrong Answer

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+a[1][0]//2)

Submission status: Wrong Answer

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,D))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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 * d
    else:
        ans = (n // 2) * d + x

print(ans)

Submission status: Wrong Answer

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 * d
    else:
        ans = (n // 2) * d + x

print(ans)

Submission status: Wrong Answer

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]):
  u = N // q
  if N < q * u:
    continue
  N -= q * u
  #print((q, u))
  tanka += Y * u
  if N <= 0:
    break
 
print("{:.0f}".format(tanka))

Submission status: Wrong Answer

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]):
  u = N // q
  N -= q * u
  #print((q, u))
  tanka += Y * u
  if N <= 0:
    break
 
print("{:.0f}".format(tanka))

Submission status: Wrong Answer

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

m += (N // 1) * S
N = N % 1.0

m += (N // 0.5) * H
N = N % 0.5

m += (N // 0.25) * Q

print(int(m))

Submission status: Wrong Answer

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 // 1) * S
N = N % 1

m += (N // 0.5) * H
N = N % 0.5

m += (N // 0.25) * Q

print(int(m))

Submission status: Wrong Answer

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
left = left%1
cost += (left//0.5)*H
left = left%0.5
cost += (left//0.25)*Q
print(int(cost))

Submission status: Wrong Answer

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 = N // sortedtea[i][3]
        N -= sortedtea[i][3] * numbottles
        price += sortedtea[i][2] * numbottles

print(int(price))

Submission status: Wrong Answer

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 = N // sortedtea[i][3]
        N -= sortedtea[i][3] * numbottles
        price += sortedtea[i][2] * numbottles

print(price)

Submission status: Wrong Answer

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)
print(min(N*x ,ceil(N/2)*D,floor(N/2)*D + x))

Submission status: Wrong Answer

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)
a = 4*q
b = 2*q +h
c = 2*h
print(ans+min(a,b,c,s))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

cq = Q * 8
ch = H * 4
cs = S * 2
cd = D
most_effective = min(cq, ch, cs, cd)

if most_effective == cd:
    if N % 2 == 1:
        dcost = N // 2 * D
        most_effective = min(cq, ch, cs)
        if most_effective == cs:
            print(dcost + S)
        elif most_effective == ch:
            print(dcost + 2 * H)
        else:
            print(dcost + 4 * Q)
    else:
        print(N / 2 * D)
elif most_effective == cs:
    print(N * S)
elif most_effective == ch:
    print(N * 2 * H)
elif most_effective == cq:
    print(N * 4 * Q)

Submission status: Wrong Answer

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

price = [8*Q, 4*H, 2*S, D]
ans = 0
volume = [2,1,0.5,0.25]
order = [D, S, H, Q]

for i in range(2):
  ans += N // volume[i] * min(price)
  N = N % volume[i]
  price.remove(order[i])
  price = list(map(lambda x:x/2, price))

print(int(ans))

Submission status: Wrong Answer

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

price = [8*Q, 4*H, 2*S, D]
ans = 0
volume = [2,1,0.5,0.25]
order = [D, S, H, Q]

for i in range(4):
  ans += N // volume[i] * min(price)
  N = N % volume[i]
  price.remove(order[i])
  price = list(map(lambda x:x/2, price))

print(int(ans))

Submission status: Wrong Answer

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

nq = q * 4
nh = h * 2
nd = d / 2

ans = 0
if n >= 2:
  ans += 2 * (n // 2 * min(nq, nh, s, nd))

if n % 2 == 1:
  ans += min(nq, nh, s)
  print(int(ans))
else:
  print(int(ans))

Submission status: Wrong Answer

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

nq = q * 4
nh = h * 2
nd = d / 2

ans = 0
if n > 2:
  ans += 2 * (n // 2 * min(nq, nh, s, nd))

if n % 2 == 1:
  ans += min(nq, nh, s)
  print(int(ans))
else:
  print(int(ans))