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:
p = list(map(int, input().split()))
n = int(input())
l = []
s = [0.25, 0.5, 1, 2]

l = [[p[0]*4, 0], [p[1]*2, 1], [p[2], 2], [p[3]/2, 3]]
l.sort()


def only1L():
    return min(p[0]*4, p[0]*2+p[1], p[1]*2, p[2])


if (s[l[0][1]] == 2):
    print(int(p[l[0][1]] * (n // s[l[0][1]])) + only1L())
elif (n == 1):
    print(only1L())
else:
    print(int(l[0][0] * (n / s[l[0][1]])))

Submission status: Wrong Answer

Solution code:
import math

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

qq = [q, q, 25]
hh = [math.floor(h/2), h, 50]
ss = [math.floor(s/4), s, 100]
dd = [math.floor(d/8), d, 200]
qhsd = [qq, hh, ss, dd]
qhsd.sort()

#print('##########')
#print(qq, hh, ss, dd)
#print(qhsd)
#print('##########')

ans = 0
for i in range(4):
    num = n//qhsd[i][2]
    n -= num*qhsd[i][2]
    ans += num*qhsd[i][1]
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

qq = [q, q, 0.25]
hh = [math.floor(h/2), h, 0.5]
ss = [math.floor(s/4), s, 1]
dd = [math.floor(d/8), d, 2]
qhsd = [qq, hh, ss, dd]
qhsd.sort()

ans = 0
for i in range(4):
    num = n//qhsd[i][2]
    n -= num*qhsd[i][2]
    ans += num*qhsd[i][1]
print(int(ans))

Submission status: Wrong Answer

Solution code:
l=list(map(float,input().split()))
size=[0.25,0.5,1.,2.]
N=int(input())
dic={}
cost=[]
for i in range(4):
  cost.append(l[i]/size[i])
sorted_cost=sorted(cost,reverse=True)
INDEX=[]
for i in range(4):
  dic[sorted_cost[i]]=i
for i in range(4):
  INDEX.append(dic[cost[i]])
ans=0
while N!=0:
  v=INDEX.pop(-1)
  S=size[v]
  M=l[v]
  v2=N//S
  N-=v2*S
  ans+=v2*M
print(int(ans))

Submission status: Wrong Answer

Solution code:
l=list(map(int,input().split()))
size=[0.25,0.5,1,2]
N=int(input())
dic={}
cost=[]
for i in range(4):
  cost.append(l[i]/size[i])
sorted_cost=sorted(cost,reverse=True)
INDEX=[]
for i in range(4):
  dic[sorted_cost[i]]=i
for i in range(4):
  INDEX.append(dic[cost[i]])
ans=0
while N!=0:
  v=INDEX.pop(-1)
  S=size[v]
  M=l[v]
  v2=N//S
  N-=v2*S
  ans+=v2*M
print(int(ans))

Submission status: Wrong Answer

Solution code:
l=list(map(int,input().split()))
size=[0.25,0.5,1,2]
NN=int(input())
ans=10**18

for i in range(2**4):
  tmp=[]
  for j in range(4):
    if (i>>j)&1:
      tmp.append(j)
  ans2=0
  N=NN
  cost=[]
  for index in tmp:
    cost.append(l[index]/size[index])
  dic={}
  sorted_cost=sorted(cost,reverse=True)
  for index in range(len(tmp)):
    dic[sorted_cost[index]]=index
  Tmp=[]
  for I in range(len(cost)):
    Tmp.append(dic[cost[I]])
  tmp=Tmp
  while N!=0 and len(tmp)!=0:
    v=tmp.pop(-1)
    S=size[v]
    M=l[v]
    v2=N//S
    N-=v2*S
    ans2+=v2*M
  if N==0:
    ans=min(ans,ans2)
print(int(ans))

Submission status: Wrong Answer

Solution code:
l=list(map(int,input().split()))
NN=int(input())
ans=10**30
size=[0.25,0.5,1,2]
for i in range(2**4):
  tmp=[]
  for j in range(4):
    if (i>>j)&1:
      tmp.append(j)
  ans2=0
  N=NN
  while N!=0 and len(tmp)!=0:
    v=tmp.pop(-1)
    S=size[v]
    M=l[v]
    v2=N//S
    N-=v2*S
    ans2+=v2*M
  if N==0:
    ans=min(ans,ans2)
print(int(ans))

Submission status: Wrong Answer

Solution code:
l=list(map(int,input().split()))
NN=int(input())
ans=10**17
size=[0.25,0.5,1,2]
for i in range(2**4):
  tmp=[]
  for j in range(4):
    if (i>>j)&1:
      tmp.append(j)
  ans2=0
  N=NN
  while N!=0 and len(tmp)!=0:
    v=tmp.pop(-1)
    S=size[v]
    M=l[v]
    v2=N//S
    N-=v2*S
    ans2+=v2*M
  if N==0:
    ans=min(ans,ans2)
print(int(ans))

Submission status: Wrong Answer

Solution code:
def main():
    q, h, s, d = map(int, input().split())
    target = int(input())
    value = [(q, q, 0.25), (h, h / 2, 0.5), (s, s / 4, 1.0), (d, d / 8, 2.0)]
    value.sort(key=lambda x: x[1])
    answer = 0
    target_even = target // 2 * 2
    for i in range(4):
        answer += (target_even // value[i][2]) * value[i][0]
        target_even %= value[i][2]
        if target_even == 0:
            break
    if target % 2:
        answer += min(q * 4, h * 2, s)
    print(int(answer))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    q, h, s, d = map(int, input().split())
    target = int(input())
    value = [(q, q, 0.25), (h, h / 2, 0.5), (s, s / 4, 1.0), (d, d / 8, 2.0)]
    value.sort(key=lambda x: x[1])
    answer = 0
    for i in range(4):
        answer += (target // value[i][2]) * value[i][0]
        target %= value[i][2]
        if target == 0:
            break
    print(int(answer))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

A.append(4*Q)
A.append(2*H)
A.append(S)
A.append(D/2)

if min(A)==A[0]:
  print(N*A[0])
elif min(A)==A[1]:
  print(N*A[1])
elif min(A)==A[2]:
  print(N*A[2])
else:
  a = N//2
  p = a*D
  if A[0]<=A[1] and A[0]<=A[2]:
    p += A[0]
  elif A[1]<=A[2] and A[1]<=A[0]:
    p += A[1]
  else:
    p += A[2]
  print(p)

Submission status: Wrong Answer

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

ans = 0

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

Submission status: Wrong Answer

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

rate = {"Q": 4 * Q, "H": 2 * H, "S": S, "D": 1 / 2 * D}
price = 0
score_sorted = sorted(rate.items(), key=lambda x: x[1])
for x in score_sorted:
    if x[0] == "D" and N >= 2:
        div, mod = divmod(N, 2)
        N = mod
        price = D * div
    elif x[0] == "S":
        price += S * N
        break
    elif x[0] == "H":
        price += S * H * 2
        break
    elif x[0] == "Q":
        price += S * Q * 4
        break
    if N == 0:
        break
print(price)

Submission status: Wrong Answer

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

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

	ans = 0

	if N == 1:
		ans = s
	elif N % 2 == 0:
		if s*2 < d:
			ans = s * N
		else:
			ans = d * N / 2
	elif N % 2 == 1:
		if s*2 < d:
			ans = s * N
		else:
			ans = d * (N-1)/2 + s

	print(int(ans))

Submission status: Wrong Answer

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

q=q*4
h=h*2

if q<s:
	s=q
if h<s:
	s=h
if s*2<=d:
	print(x*s)
else:
	if x%2==0:
		print(round(x*d/2))
	else:
		print((x//2)*d+s)

Submission status: Wrong Answer

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

q=q*4
h=h*2
d=d/2

ans=0
if q<=h and q<=s and q<=d:
	ans=x*q
	x=0
elif h<=q and h<=s and h<=d:
	ans=x*h
	x=0
elif s<=q and s<=h and s<=d:
	ans=x*s
	x=0
else:
	ans=ans+round((x//2)*d*2)
	x=x-((x//2)*2)
if x>0:
	if q<=h and q<=s:
		ans=ans+q
	elif h<=q and h<=s:
		ans=ans+h
	else :
		ans=ans+s
print(ans)

Submission status: Wrong Answer

Solution code:
q,h,s,d = map(int,input().split())
n = int(input())
h = min(q*2,h)
s = min(h*2,s)
d = min(s*2,d)
ans = 0
a_list = [2,1,0.5,0.25]
a = []
for i in a_list:
    a.append(n//i)
    n = n%i
print(int(a[0]*d+a[1]*s+a[2]*h+a[3]*q))

Submission status: Wrong Answer

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

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

if n >= 2:
  ans += min(8 * q, 4 * h, 2 * s, d) * math.floor(n /2)
  
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())

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

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, D*N//2))
else:
    if N == 1:
        print(min(A, D))
    else:
        print(min(A*N, D*(N+1)//2, D*(N//2)+A))

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, D*N//2))
else:
    print(min(A*N, D*(N+1)//2, D*N//2+A))

Submission status: Wrong Answer

Solution code:
q,h,s,d=map(int,input().split())
n=int(input())
p=[[q*8,0.25],[h*4,0.5],[s*2,1],[d,2]]
p.sort()
n0=0
ans=0
i=0
while n>0:
    ans+=p[i][0]*(n//p[i][1])//(2//p[i][1])
    n-=p[i][1]*(n//p[i][1])
    i+=1
print(int(ans))

Submission status: Wrong Answer

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

import math
from collections import defaultdict

a = [int(s) for s in input().split()]
r = int(input())

q = a[0] / 0.25
h = a[1] / 0.5
s = a[2]
d = a[3] / 2

s = [(q, 0.25), (h, 0.5), (s, 1), (d, 2)]
p = sorted(s, key=lambda x:x[0])

ans = 0

for u, q in p:
    c = r//q
    ans += (u * q) * c
    r -= (q * c)

print(int(ans))

Submission status: Wrong Answer

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

import math
from collections import defaultdict

a = [int(s) for s in input().split()]
r = int(input())

q = int(a[0] / 0.25)
h = int(a[1] / 0.5)
s = a[2]
d = int(a[3] / 2)

s = [(q, 0.25), (h, 0.5), (s, 1), (d, 2)]
p = sorted(s, key=lambda x:x[0])

ans = 0

for u, q in p:
    c = r//q
    ans += (u * q) * c
    r -= (q * c)


print(int(ans))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

tmp = [4 * q, 2 * h, s, d / 2]
tmp.sort()
if tmp[0] == d / 2:
    if tmp[1] == s:
        ans = d * (n // 2) + s
    if tmp[1] == 2 * h:
        ans = d * (n // 2) + 2 * h
    if tmp[1] == 4 * q:
        ans = d * (n // 2) + 4 * q
if tmp[0] == s:
    ans = s * n
if tmp[0] == 2 * h:
    ans = h * n * 2
if tmp[0] == 4 * q:
    ans = q * n * 4
print(ans)

Submission status: Wrong Answer

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

ans = 0
s = [(Q, 0.25), (H, 0.5), (S, 1.0), (D, 2.0)]

ans = float("inf")
for x in permutations(s):
    tmp = 0
    n = N
    for a, b in x:
        tmp += (n // b)*a
        n %= b
    ans = min(ans, tmp)
print(int(ans))

Submission status: Wrong Answer

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

s = [(Q / 0.25, 0.25), (H / 0.5, 0.5), (S, 1.0), (D / 2, 2.0)]
s.sort()
ans = 0
for i in range(4):
    ans += (N // s[i][1]) * (s[i][0] * s[i][1])
    N %= s[i][1]
print(int(ans))

Submission status: Wrong Answer

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

n/=2
ans+=n*min([2*q,2*h,2*s,d])
print(int(ans))

Submission status: Wrong Answer

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

n/=2
ans+=n*min([2*Q,2*H,2*s,d])
print(int(ans))

Submission status: Wrong Answer

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]:
        ans += n // 2 * d
        ans += min(value[0:3])
    else:
        ans += min(value) * n

    print(ans)

Submission status: Wrong Answer

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

q /= 0.25
h /= 0.5
s /= 1
d /= 2

li = [(q, 0.25), (h, 0.5), (s, 1), (d, 2)]
li.sort()

ans = 0
for i in range(len(li)):
    if n < li[i][1]:
        continue
    n, r = divmod(n, li[i][1])
    ans += n * li[i][0] * li[i][1]
    if r == 0:
        break
print(int(ans))

Submission status: Wrong Answer

Solution code:
import math

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

qq = q
hh = math.ceil(h/2)
ss = math.ceil(s/4)
dd = math.ceil(d/8)

items = [[qq, q, 0.25], [hh, h, 0.5], [ss, s, 1], [dd, d, 2]]
items = sorted(items, key=lambda x: x[0])

ans = 0
while n != 0:
    for item in items:
        if n >= item[2]:
            ans += item[1]
            n -= item[2]
            break

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    Q, H, S, D = Scanner.map_int()
    N = Scanner.int()
    ans = 0
    if D <= S * 2:
        ans += (N // 2) * D
        N %= 2
    if S <= H * 2:
        ans += N * S
        N = 0
    if H <= Q * 2:
        ans += N * 2 * H
        N = 0
    ans += N * 4 * Q
    print(ans)
    return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
Q,H,S,D = map(int,input().split())
N = int(input())
D = min(D,min(S*2,min(H*4,Q*8)))
S = min(S,min(H*2,Q*4))
H = min(H,Q*2)
ans = 0
QHSD = [Q,H,S,D]
l_QHSD = [0.25,0.5,1,2]
for i in range(3,0,-1):
	ans += N // l_QHSD[i] * QHSD[i]
	N = N - N // l_QHSD[i] * l_QHSD[i]
print(int(ans))

Submission status: Wrong Answer

Solution code:
al = list(map(int,input().split()))
bl = al[:]
n = int(input())

bl[0] = al[0] * 8
bl[1] = al[1] * 4
bl[2] = bl[2] * 2

import numpy as np

t = list(np.argsort(bl))
if t[3] == 0:
    idx = t.index(1)
    print(n//2 * bl[3] + (n%2) * bl[idx] / 2)
else:
    idx = t.index(0)
    print(n * bl[idx] / 2)

Submission status: Wrong Answer

Solution code:
al = list(map(int,input().split()))
bl = al[:]
n = int(input())

bl[0] = al[0] * 8
bl[1] = al[1] * 4
bl[2] = bl[2] * 2

import numpy as np

t = list(np.argsort(bl))
if t[3] == 0:
    idx = t.index(1)
    print(n//2 * bl[3] + (n%2) * bl[idx] // 2)
else:
    idx = t.index(0)
    print(n * bl[idx] // 2)

Submission status: Wrong Answer

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

cost=[Q,H,S,D]

ans=10**18
for index,item in enumerate(cost):
    temp=item*(N//2**(index-2))

    for jndex,jtem in enumerate(cost[:3]):
        ans=int(min(ans,temp+jtem*(N%(2**(index-2)))/2**(jndex-2)))

print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
cost=list(map(int,input().split()))

for i in range(4):
    cost[i]/=2**(i-2)
    
cost=list(map(int,cost))

N=int(input())

if min(cost)==cost[3]:
    print(((N//2*2)*cost[3]+(N%2)*min(cost[:3])))
else:
    print((min(cost)*N))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
cost=list(map(int,input().split()))

for i in range(4):
    cost[i]/=2**(i-2)
    
cost=list(map(int,cost))

N=int(input())

if min(cost)==cost[3]:
    print(int((N//2*2)*cost[3]+(N%2)*min(cost[:3])))
else:
    print(int(min(cost)*N))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
cost=list(map(int,input().split()))

for i in range(4):
    cost[i]/=2**(i-2)

N=int(input())

if min(cost)==cost[3]:
    print(((N//2*2)*cost[3]+(N%2)*min(cost[:3])))
else:
    print((min(cost)*N))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
cost=list(map(int,input().split()))

for i in range(4):
    cost[i]/=2**(i-2)

N=int(input())


if min(cost)==cost[3]:
    print(int((N//2*2)*cost[3]+(N%2)*min(cost[:3])))
else:
    print(int(min(cost)*N))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
q,h,s,d=nm()
n=ni()
l=[]
Q=8*q
H=4*h
S=2*s
D=d
l.append([Q,q,0.25])
l.append([H,h,0.5])
l.append([S,s,1])
l.append([D,d,2])

l.sort(key=lambda x:x[0])

i=0
ans=0
while n>0:
    qq=n//l[i][2]
    if n>=qq*l[i][2]:
        n-=qq*l[i][2]
        ans+=qq*l[i][1]
        i+=1
        continue
    i+=1
print(int(ans))

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
q,h,s,d=map(int,input().split())
n=int(input())
li=[[0.25,q],[0.5,h],[1,s]]
li.sort(key=lambda x: x[1]/x[0])
li=[[1,int(li[0][1])],[2,d]]
# print(li)
li.sort(key=lambda x: x[1]/x[0])
ans=0
now=0
for i in range(2):
    ko=(n-now)//li[i][0]
    ans+=ko*li[i][1]
    now+=ko*li[i][0]
    now=int(now)
    # print(ans,now)
print(int(ans))

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
q,h,s,d=map(int,input().split())
n=int(input())
li=[[0.25,q],[0.5,h],[1,s]]
li.sort(key=lambda x: x[1]/x[0])
li=[[1,int(li[0][1])],[2,d]]
# print(li)
ans=0
now=0
for i in range(2):
    ko=(n-now)//li[i][0]
    ans+=ko*li[i][1]
    now+=ko*li[i][0]
    now=int(now)
    # print(ans,now)
print(int(ans))

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
q,h,s,d=map(int,input().split())
n=int(input())
li=[[0.25,q],[0.5,h],[1,s],[2,d]]
li.sort(key=lambda x: x[1]/x[0])
# print(li)
ans=0
now=0
for i in range(4):
    ko=(n-now)//li[i][0]
    ans+=ko*li[i][1]
    now+=ko*li[i][0]
    now=int(now)
    # print(ans,now)
print(int(ans))

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
q,h,s,d=map(int,input().split())
n=int(input())
li=[[0.25,q],[0.5,h],[1,s],[2,d]]
li.sort(key=lambda x: x[1]/x[0])
# print(li)
ans=0
now=0
for i in range(4):
    ko=(n-now)//li[i][0]
    ans+=ko*li[i][1]
    now+=ko*li[i][0]
    # print(ans,now)
print(int(ans))

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(((N-1)*temp+min(4*Q,2*H,S)))
    else:
        print((N*temp))

Submission status: Wrong Answer

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

if d / 2 != min(4 * q, 2 * h, s, d / 2):
    print(n * min(4 * q, 2 * h, s))
else:
    if n % 2 == 0:
        print(n / 2 * d)
    else:
        print(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())

cost_2000 = min(8*q,4*h,2*s,d)
cost_1000 = min(4*q,2*h,s)
cost_500 = min(2*q,h)
cost_250 = q

c = [cost_2000,cost_1000,cost_500,cost_250]
amo = [2,1,0.5,0.25]
ans = 0
for i in range(4):
	uni,mod = divmod(n,amo[i])
	ans += c[i] * uni
	n = mod

print(int(ans))

Submission status: Wrong Answer

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

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

PS.sort(key=lambda x: x[0])


R = N
ans = 0
for i in range (4):
    if R == 0:
        break
    elif R >= PS[i][1]:
        ans += PS[i][0] * PS[i][1] / 2 * (R // PS[i][1])
        R = R % PS[i][1]

print(int(ans))

Submission status: Wrong Answer

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

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

PS.sort(key=lambda x: x[0])


R = N
ans = 0
for i in range (4):
    if R == 0:
        break
    elif R >= PS[i][1]:
        ans += PS[i][0] * PS[i][1] // 2 * (R // PS[i][1])
        R = R % PS[i][1]

print(int(ans))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    q, h, s, d = LI()
    n = II()
    q4 = q * 4
    h2 = h * 2
    l1 = min(q4, h2, s)
    l2 = min(l1 * 2, d)
    print((n >> 1) * l2 + (n & 1 * l1))
    
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	Q, H, S, D = MAP()
	N = INT()

	# 単価、単位価格、容量
	A = [[Q/0.25, Q, 0.25], [H/0.5, H, 0.5], [S/1.0, S, 1.0], [D/2.0, D, 2.0]]
	A.sort()
	# print(A)

	ans = 0
	for a in A:
		cost, price, amt = a
		if N >= amt:
			ans += (N//amt) * price
			N -= (N//amt) * amt
	
	print(int(ans))
	
	

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
Q, H, S, D = map(int, input().split(' '))
N = int(input())

p1 = Q
p2 = min([2 * Q, H])
p3 = min([4 * Q, 2 * H, S])
p4 = min([8 * Q, 4 * H, 2 * S, D])



n4 = N // 2
n3 = (N - n4 * 2) // 1
n2 = (N - n4 * 2 - n3 * 1) // 0.5
n1 = N - n4 * 2 - n3 * 1 - n2 * 0.5

ans = p1 * n1 + p2 * n2 + p3 * n3 + p4 * n4


print(int(ans))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(Q: int, H: int, S: int, D: int, N: int):
    t = [
        [0.25, Q, Q],
        [0.50, H, H/2],
        [1, S, S/4],
        [2, D, D/8]
    ]

    t = sorted(t, key=lambda x:(x[2], x[0]))
    # print(t)

    nokori = int(N % t[0][0])
    ans = int(t[0][2]*4*(N-nokori))
    # print(nokori, ans)

    if nokori > 0:
        ans += int(t[1][2]*4)
            
    print(ans)
    
    return



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

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(Q: int, H: int, S: int, D: int, N: int):
    t = [
        [0.25, Q, Q],
        [0.50, H, H/2],
        [1, S, S/4],
        [2, D, D/8]
    ]

    t = sorted(t, key=lambda x:(x[2], x[0]))
    # print(t)

    nokori = N % t[0][0]
    ans = t[0][2]*4*(N-nokori)

    if nokori > 0:
        ans += t[1][2]*4
            
    print(int(ans))
    
    return



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

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(Q: int, H: int, S: int, D: int, N: int):
    t = [
        [0.25, Q, Q],
        [0.50, H, H/2],
        [1, S, S/4],
        [2, D, D/8]
    ]

    # print(Q, H/2, S/4, D/8)

    t = sorted(t, key=lambda x:x[2])
    # print(t)

    nokori = N % t[0][0]
    ans = t[0][2]*4*(N-nokori)

    # print(ans, nokori)

    if nokori > 0:
        ans += t[1][2]*4
            
    print(int(ans))
    
    return



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

Solution code:
Q, H, S, D = map(int, input().split())
q = Q * 4
h = H * 2
s = S
d = D / 2

arr = [(q, Q, 0.25), (h, H, 0.5), (s, S, 1.0), (d, D, 2.0)]
arr.sort()

N = int(input())

ans = 0
while N > 0:
    for _, cost, quantity in arr:
        if N >= quantity:
            ans += (N // quantity) * cost
            N -= (N // quantity) * quantity
print(int(ans))

Submission status: Wrong Answer

Solution code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    ls = list(map(int, readline().split()))
    n = int(readline())
    ls[1] = min(ls[1], ls[0] * 2)
    ls[2] = min(ls[2], ls[1] * 2)
    ls[3] = min(ls[3], ls[2] * 2)
    t = 0
    for i in range(3, -1, -1):
        if i == 3:
            t += n // 2 * ls[i]
            n -= n // 2 * 2
        elif i == 2:
            t += n // 1 * ls[i]
            n -= n // 1 * 1
        elif i == 1:
            t += n / 0.5 * ls[i]
            n -= n // 0.5 * 0.5
        else:
            t += n // 0.25 * ls[i]
            n -= n // 0.25 * 0.25
    print(int(t))


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
yen = list(map(int,input().split()))
N = int(input())
lista = [4*yen[0], 2*yen[1], yen[2]]

yen1 = min(lista)
if 2*yen1 <= yen[3]:
    print(N*yen1)
else:
    if N%2 == 0:
        print(int(N*yen[3]/2))
    else:
        print(int( (N-1)*(yen[3]/2) + yen1))

Submission status: Wrong Answer

Solution code:
yen = list(map(int,input().split()))
N = int(input())
lista = [4*yen[0], 2*yen[1], yen[2]]

yen1 = min(lista)
if 2*yen1 <= yen[3]:
    print(N*yen1)
else:
    if N%2 == 0:
        print(int(N*yen[3]//2))
    else:
        print(int( (N-1)*(yen[3]//2) + yen1))

Submission status: Wrong Answer

Solution code:
a,b,c,d=map(int,input().split())
x=int(input())
ll=[a,b,c,d]
l=[8*a, 4*b, 2*c, d*1]
s_l=[]
for i in range(4):
 n=l.index(min(l))
 s_l.append(n)
 l[n]=float('inf')

ans=0
for i in s_l:
 r=2 if i==3 else 1 if i==2 else 0.5 if i==1 else 0.25
 ans+=(x//r)*ll[i]
 x-=(x//r)*r
print(int(ans))

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