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:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

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

    if n==1:
        print(sp1)
    elif n%2==0:
        print(n*dp2)
    else:
        c=n//2
        print(c*dp2+sp1)

if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    q,h,s,d = map(int,input().split())
    n = int(input())
    q=4*q
    h=2*h
    d=d//2
    p1=min(q,h,s)
    p2=min(2*q,2*h,2*s,2*d)

    if n%2==0:
        print(n*p2)
    else:
        c=n//2
        print(c*p2+p1)

if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    q,h,s,d = map(int,input().split())
    n = int(input())
    q=4*q
    h=2*h
    d=d//2
    p1=min(q,h,s)
    p2=min(2*s,2*d)

    if n%2==0:
        print(n*p2)
    else:
        c=n//2
        print(c*p2+p1)

if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    q,h,s,d = map(int,input().split())
    n = int(input())
    q=4*q
    h=2*h
    d=d//2
    p1=min(q,h,s)
    p2=min(2*p1,2*d)

    if n%2==0:
        print(n*p2)
    else:
        c=n//2
        print(c*p2+p1)

if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
Q, H, S, D = map(int, input().split())
L = int(input())
quantities = [(8*Q, "Q"), (4*H, "H"), (2*S, "S"), (D, "D")]
rest = {"Q": 4*Q, "H": 2*H, "S": S, "D": D//2}
quantities.sort()
if quantities[0][1] == "D" and L%2 != 0:
  print(L//2*D + rest[quantities[1][1]])
else:
  print(L*rest[quantities[0][1]])

Submission status: Wrong Answer

Solution code:
def solve():
    Q, H, S, D = [int(i) for i in input().split()]
    P = [(0.25, Q), (0.5, H), (1, S), (2, D)]
    P.sort(key=lambda t: t[1] / t[0])
    N = int(input())
    ans = 0
    for p in P:
        if N == 0:
            break
        x, y = p
        n = N // x
        ans += n * y
        N -= n * x
    print(int(ans))


if __name__ == "__main__":
    solve()

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); x = 0
x += n//2*d; n %= 2; x += n//1*s; n %= 1; x += n//0.5*h; n %= 0.5; x += n//0.25*q
print(int(x))

Submission status: Wrong Answer

Solution code:
Q,H,S,D=map(int,input().split())
Q*=4
H*=2
a=Q*2
b=H*2
c=S*2
d=D
s=min([a,b,c,d])
p=int(input())
print(((p//2)*s)+min([Q,H,D,S]))

Submission status: Wrong Answer

Solution code:
Q, H, S, D = map(int, input().split())
n = int(input())
coffee = [[Q*4, 0.25, Q], [H*2, 0.5, H], [S, 1, S], [D/2, 2, D]]
coffee_cost = sorted(coffee)
cost = 0
Qt = n
for i in range(4):
    cost += (Qt // coffee_cost[i][1]) * coffee_cost[i][2]
    Qt -= (Qt // coffee_cost[i][1]) * coffee_cost[i][1]
    if Qt == 0:
        print(int(cost))
        exit()

Submission status: Wrong Answer

Solution code:
Q, H, S, D = map(int, input().split())
N = int(input())
x = N % 2
y = N // 2
arr = [4*Q*x, 2*H*x, S*x]
arr1 = [8*Q*y, 4**H*y, 2*S*y, D*y]
#if N % 2 == 0:
#  arr.append(int(0.5*D*N))
#else:
#  arr.append(int(0.5*D*(N-1)+ min(S, 2*H, 4*Q)))
   
print(min(arr) + min(arr1))

Submission status: Wrong Answer

Solution code:
Q, H, S, D = map(int, input().split())
N = int(input())
arr = [4*Q*N, 2*H*N, S*N]
if N % 2 == 0:
  arr.append(int(0.5*D*N))
else:
  arr.append(int(0.5*D*(N-1)+ min(S, 2*H, 4*Q)))
    
print(int(min(arr)))

Submission status: Wrong Answer

Solution code:
Q, H, S, D = map(int, input().split())
N = int(input())
arr = [4*Q*N, 2*H*N, S*N]
if N % 2 == 0:
  arr.append(int(0.5*D*N))
else:
  arr.append(int(0.5*D*(N-1)+ min(S, 2*H, 4*Q)))
    
print(min(arr))

Submission status: Wrong Answer

Solution code:
Q, H, S, D = map(int, input().split())
N = int(input())
arr = [4*Q*N, 2*H*N, S*N]
if N % 2 == 0:
  arr.append(int(0.5*D*N))
else:
  arr.append(int(0.5*D*(N-1)+ min(S, 2*H, 4*Q)))
    
print(min(arr))

Submission status: Wrong Answer

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

if n % 2 == 0:
    price = min(a) * n / 2
if n % 2 == 1:
    price = min(a) * (n-1) / 2
    a.remove(d)
    price = price + min(a) / 2

print(int(price))

Submission status: Wrong Answer

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

if n % 2 == 0:
    price = int(min(a) * n / 2)
else:
    price = int(min(a) * (n-1) / 2)
    a.remove(d)
    price = price + int(min(a) / 2)

print(int(price))

Submission status: Wrong Answer

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

if n % 2 == 0:
    price = min(a) * n / 2
else:
    price = min(a) * (n-1) / 2
    a.remove(d)
    price = price + min(a) / 2

print(int(price))

Submission status: Wrong Answer

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

if n == 1:
    a.remove(d)
    price = min(a) / 2
elif n % 2 == 0:
    price = min(a) * n / 2
else:
    price = min(a) * (n-1) / 2
    a.remove(d)
    price = price + min(a) / 2

print(int(price))

Submission status: Wrong Answer

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

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

ans = 0

for i in cost:
    L = float(i[0])
    C = i[1] * L / 2
    
    if L <= n:
        ans += C * (n//L)
        n %= L
        
print(int(ans))

Submission status: Wrong Answer

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

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

ans = 0

for i in cost:
    L = float(i[0])
    C = i[1] * L // 2
    
    if L <= n:
        ans += C * (n//L)
        n %= L
        
print(int(ans))

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)
ans=0
data=[[2,d],[1,s],[float(0.5),h],[float(0.25),q]]
for i in range(4):
  ans+=(n//data[i][0])*data[i][1]
  n-=(n//data[i][0])*data[i][0]
print(int(ans))

Submission status: Wrong Answer

Solution code:
Q, H, S, D = map(int, input().split())
N = int(input())
arr = [4*Q*N, 2*H*N, S*N]
if N % 2 == 0:
  arr.append(int(0.5*D*N))
else:
  if N >= 3:
    arr.append(int(0.5*D*(N-1)+ min(S, 2*H, 4*Q)))
    
print(min(arr))

Submission status: Wrong Answer

Solution code:
#A - Ice Tea Store
Q,H,S,D = map(int,input().split())
N = int(input())

#2Lあたり
Q2,H2,S2,D2 = 8*Q,4*H,2*S,D
lis = [(0.25,Q2),(0.5,H2),(1,S2),(2,D)]
lis = sorted(lis,reverse = False,key = lambda x:x[1])
#得なサイズの値段の昇順
a,b,c,d = lis[0][1],lis[1][1],lis[2][1],lis[3][1]

#一番得なサイズの量
A,B,C,D = lis[0][0],lis[1][0],lis[2][0],lis[3][0]

if A == 2:
    cnt_A = N//2
    cnt_B = N%2
    pay = a*cnt_A + (cnt_B/B)*(b/(2/B))
else:
    pay = (N//A) * (a/(2/A))
print(int(pay))

Submission status: Wrong Answer

Solution code:
#A - Ice Tea Store
Q,H,S,D = map(int,input().split())
N = int(input())

#2Lあたり
Q2,H2,S2,D2 = 8*Q,4*H,2*S,D
lis = [(0.25,Q2),(0.5,H2),(1,S2),(2,D)]
lis = sorted(lis,reverse = False,key = lambda x:x[1])
#得なサイズの値段の昇順
a,b,c,d = lis[0][1],lis[1][1],lis[2][1],lis[3][1]

#一番得なサイズの量
A,B,C,D = lis[0][0],lis[1][0],lis[2][0],lis[3][0]

if A == 2:
    cnt_A = N//2
    cnt_B = N%2
    pay = a*cnt_A + (cnt_B/B)*(b/(2/B))
else:
    pay = (N//a) * (a/(2/A))
print(int(pay))

Submission status: Wrong Answer

Solution code:
#A - Ice Tea Store
Q,H,S,D = map(int,input().split())
N = int(input())

#2Lあたり
Q2,H2,S2,D2 = 8*Q,4*H,2*S,D
lis = [(0.25,Q2),(0.5,H2),(1,S2),(2,D)]
lis = sorted(lis,reverse = False,key = lambda x:x[1])
#得なサイズの値段の昇順
a,b,c,d = lis[0][1],lis[1][1],lis[2][1],lis[3][1]

#一番得なサイズの量
A,B,C,D = lis[0][0],lis[1][0],lis[2][0],lis[3][0]
pay = 0

if A == 2:
    cnt_A = N//2
    cnt_B = N%2
    pay = D*cnt_A + cnt_B*(b/(2/B))
else:
    pay = (N//a) * (a/(2/A))
print(int(pay))

Submission status: Wrong Answer

Solution code:
#A - Ice Tea Store
Q,H,S,D = map(int,input().split())
N = int(input())

#2Lあたり
Q2,H2,S2,D2 = 8*Q,4*H,2*S,D
lis = [(0.25,Q2),(0.5,H2),(1,S2),(2,D)]
lis = sorted(lis,reverse = False,key = lambda x:x[1])
#得なサイズの値段の昇順
a,b,c,d = lis[0][1],lis[1][1],lis[2][1],lis[3][1]

#一番得なサイズの量
A,B,C,D = lis[0][0],lis[1][0],lis[2][0],lis[3][0]
pay = 0

if N<2 and (A == 2):
    cnt = (N//B)
    N -= B*cnt
    pay += (b/(2/B))*cnt
else:
    cnt = (N//A)
    N -= A*cnt#残りの量
    pay += (a/(2/A))*cnt
if N>=2:
    cnt = (N//A)
    N -= A*cnt#残りの量
    pay += (a/(2/A))*cnt
if N == 1:
    cnt = (N//B)
    N -= B*cnt
    pay += (b/(2/B))*cnt
print(int(pay))

Submission status: Wrong Answer

Solution code:
#A - Ice Tea Store
Q,H,S,D = map(int,input().split())
N = int(input())

#2Lあたり
Q2,H2,S2,D2 = 8*Q,4*H,2*S,D
lis = [(0.25,Q2),(0.5,H2),(1,S2),(2,D)]
lis = sorted(lis,reverse = False,key = lambda x:x[1])
#得なサイズの値段の昇順
a,b,c,d = lis[0][1],lis[1][1],lis[2][1],lis[3][1]

#一番得なサイズの量
A,B,C,D = lis[0][0],lis[1][0],lis[2][0],lis[3][0]

pay = 0

cnt = (N//A)
N -= A*cnt#残りの量
pay += (a/(2/A))*cnt

if N == 1:
    cnt = (N//B)
    N -= B*cnt
    pay += (b/(2/B))*cnt
print(int(pay))

Submission status: Wrong Answer

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

#2Lあたり
Q2,H2,S2,D2 = 8*Q,4*H,2*S,D
lis = [(0.25,Q2),(0.5,H2),(1,S2),(2,D)]
lis = sorted(lis,reverse = False,key = lambda x:x[1])
#得なサイズの値段の昇順
a,b,c,d = lis[0][1],lis[1][1],lis[2][1],lis[3][1]

#一番得なサイズの量
A,B,C,D = lis[0][0],lis[1][0],lis[2][0],lis[3][0]
print(lis)

pay = 0

cnt = (N//A)
N -= A*cnt#残りの量
pay += (a/(2/A))*cnt

if N == 1:
    cnt = (N//B)
    N -= B*cnt
    pay += (b/(2/B))*cnt
print(int(pay))

Submission status: Wrong Answer

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

#2Lあたり
Q2,H2,S2,D2 = 8*Q,4*H,2*S,D
lis = [(0.25,Q2),(0.5,H2),(1,S2),(2,D)]
lis = sorted(lis,reverse = False,key = lambda x:x[1])
#得なサイズの値段の昇順
a,b,c,d = lis[0][1],lis[1][1],lis[2][1],lis[3][1]

#一番得なサイズの量
A,B,C,D = lis[0][0],lis[1][0],lis[2][0],lis[3][0]

pay = 0
if N>=2 and A == 2:
    cnt = (N//A)
    N -= A*cnt#残りの量
    pay += (a/(2/A))*cnt
else:
    cnt = (N//A)
    N -= A*cnt
    pay += (a/(2/A))*cnt
if N == 1:
    cnt = (N//B)
    N -= B*cnt
    pay += (b/(2/B))*cnt
print(int(pay))

Submission status: Wrong Answer

Solution code:
#A - Ice Tea Store
Q,H,S,D = map(int,input().split())
N = int(input())

#2Lあたり
Q2,H2,S2,D2 = 8*Q,4*H,2*S,D
lis = [(0.25,Q2),(0.5,H2),(1,S2),(2,D)]
lis = sorted(lis,reverse = False,key = lambda x:x[1])
#得なサイズの値段の昇順
a,b,c,d = lis[0][1],lis[1][1],lis[2][1],lis[3][1]

#一番得なサイズの量
A,B,C,D = lis[0][0],lis[1][0],lis[2][0],lis[3][0]

pay = 0
if N>=2 and A == 2:
    cnt = (N//A)
    N -= A*cnt#残りの量
    pay += (a/(2/A))*cnt
else:
    cnt = (N//A)
    N -= A*cnt
    pay += (a/(2/A))*cnt
if (2>N>=1):
    cnt = (N//B)
    N -= B*cnt
    pay += (b/(2/B))*cnt
print(int(pay))

Submission status: Wrong Answer

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

q, h, s, d = 8 * Q, 4 * H, 2 * S, D
P = [q, h, s, d]
P = sorted(P)

ans = 0
for i in P:
    if i == d:
        if N // 2 > 0:
            x = N // 2
            ans += x * D
            N -= 2 * x
            
            x = 0
            
    if i == s:
        if N // 1 > 0:
            x = N // 1
            ans += x * S
            N -= x
            
            x = 0
            
    if i == h:
        if N // 0.5 > 0:
            
            x = N // 0.5
            ans += x * H
            N -=  0.5 * x
            
            x = 0
            
    if i == q:
        if N // 0.25 > 0:
            x = N // 0.25
            
            ans += x * Q
            N -= 0.25 *  x
            
            x = 0
            
ans = int(ans)
print(ans)

Submission status: Wrong Answer

Solution code:
a = input().split()
q = int(int(a[0]) * 4)
h = int(int(a[1]) * 2)
s = int(a[2])
t = int(min([q,h,s]))
d = int(a[3])
b = int(input())

if min([t,d/2]) == t:
  print(int(b * t))
else:
  if b % 2 == 0:
    print(int(b * d / 2))
  elif b != 1:
    print(int((b-1) * d / 2 + t))
  else:
    print(t)

Submission status: Wrong Answer

Solution code:
a = input().split()
q = int(a[0]) * 4
h = int(a[1]) * 2
s = int(a[2])
t = int(min([q,h,s]))
d = int(a[3]) / 2
b = int(input())

if min([t,d]) == t:
  print(int(b * t))
else:
  if b % 2 == 0:
    print(int(b * d))
  elif b != 1:
    print(int((b-1) * d + t))
  else:
    print(t)

Submission status: Wrong Answer

Solution code:
a = input().split()
q = int(a[0]) * 4
h = int(a[1]) * 2
s = int(a[2])
d = int(a[3]) / 2
b = int(input())

if min([q,h,s,d]) != d:
  print(int(b * min([q,h,s])))
else:
  if b % 2 == 0:
    print(int(b * d))
  elif b != 1:
    print(int((b-1) * d + min([q,h,s])))
  else:
    print(int(min([q,h,s])))

Submission status: Wrong Answer

Solution code:
a = input().split()
q = int(a[0]) * 4
h = int(a[1]) * 2
s = int(a[2])
d = int(a[3]) / 2
b = int(input())

if min([q,h,s,d]) != d:
  print(int(b * min([q,h,s])))
else:
  if b % 2 == 0:
    print(int(b * d))
  elif b != 1:
    print(int((b-1) * d) + min([q,h,s]))
  else:
    print(min([q,h,s]))

Submission status: Wrong Answer

Solution code:
a = input().split()
q = int(a[0]) * 4
h = int(a[1]) * 2
s = int(a[2])
d = int(a[3]) / 2
b = int(input())

if min([q,h,s,d]) != d:
  print(b * min([q,h,s,d]))
else:
  if b % 2 == 0:
    print(int(b * d))
  elif b != 1:
    print(int((b-1) * d) + min([q,h,s]))
  else:
    print(min([q,h,s]))

Submission status: Wrong Answer

Solution code:
#AtCoder Grand Contest 019 a
q,h,s,d=map(int,input().split())#0.25,0.5,1,2
d=min(d,s*2,h*4,q*8)
s=min(s,h*2,q*4)
h=min(h,q*2)
n=int(input())
ans=0
n-=n//d
ans+=n//d*d
n-=n//s
ans+=n//s*s
n-=n//h
ans+=n//h*h
n-=n//q
ans+=n//q*q
print(int(ans))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

ans=0
p=min(Q*8,H*4,S*2,D)
q=N
ans=p*(q//2)

p=min(Q*4,H*2,S)
q=q%2
ans+=p*(q//1)

p=min(Q*2,H)
q=q%1
ans+=p*(q//0.5)

p=Q
q=q%0.5
ans+=p*(q//0.25)

print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l = [[0.25],[0.5],[1],[2]]
tmp = list(map(int,input().split()))
q = tmp[0]

for i in range(4):
    l[i].append(tmp[i])
#print(l)
for i in range(4):
    l[i].append(l[i][1]*4/(l[i][0]*4))
#print(l)

from operator import itemgetter
l = sorted(l, key=itemgetter(2))

ans = 0
n = int(input())
for i in range(4):
    tmp = n//l[i][0]
    if tmp >= 1:
        ans += tmp * l[i][1]
        n -= tmp*l[i][0]

print(int(ans))

Submission status: Wrong Answer

Solution code:
l = [[0.25],[0.5],[1],[2]]
tmp = list(map(int,input().split()))
q = tmp[0]

for i in range(4):
    l[i].append(tmp[i])
#print(l)
for i in range(4):
    l[i].append(l[i][1]*4/(l[i][0]*4))
#print(l)

from operator import itemgetter
l = sorted(l, key=itemgetter(2))

ans = 0
n = int(input())
for i in range(4):
    tmp = n//l[i][0]
    if tmp > 0:
        ans += tmp * l[i][1]
        n -= tmp*l[i][0]

if n != 0:
    ans += n//0.25*q


print(int(ans))

Submission status: Wrong Answer

Solution code:
l = [[0.25],[0.5],[1],[2]]
tmp = list(map(int,input().split()))
for i in range(4):
    l[i].append(tmp[i])
#print(l)
for i in range(4):
    l[i].append(l[i][1]*4/(l[i][0]*4))
#print(l)

from operator import itemgetter
l = sorted(l, key=itemgetter(2))

ans = 0
n = int(input())
for i in range(4):
    tmp = n//l[i][0]
    if tmp > 0:
        ans += tmp * l[i][1]
        n -= tmp*l[i][0]

print(int(ans))

Submission status: Wrong Answer

Solution code:
l = [[0.25],[0.5],[1],[2]]
tmp = list(map(int,input().split()))
for i in range(4):
    l[i].append(tmp[i])
print(l)
for i in range(4):
    l[i].append(l[i][1]*4/(l[i][0]*4))
print(l)

from operator import itemgetter
l = sorted(l, key=itemgetter(2))

ans = 0
n = int(input())
for i in range(4):
    tmp = n//l[i][0]
    if tmp > 0:
        ans += tmp * l[i][1]
        n -= tmp*l[i][0]

print(int(ans))

Submission status: Wrong Answer

Solution code:
l = [[0.25],[0.5],[1],[2]]
tmp = list(map(int,input().split()))
for i in range(4):
    l[i].append(tmp[i])

for i in range(4):
    l[i].append(l[i][1]*4//(l[i][0]*4))
print(l)

from operator import itemgetter
l = sorted(l, key=itemgetter(2))

ans = 0
n = int(input())
for i in range(4):
    tmp = n//l[i][0]
    if tmp > 0:
        ans += tmp * l[i][1]
        n -= tmp*l[i][0]

print(int(ans))

Submission status: Wrong Answer

Solution code:
l = [[0.25],[0.5],[1],[2]]
tmp = list(map(int,input().split()))
for i in range(4):
    l[i].append(tmp[i])

for i in range(4):
    l[i].append(l[i][1]*4//l[i][0])

from operator import itemgetter
l = sorted(l, key=itemgetter(2))

ans = 0
n = int(input())
for i in range(4):
    tmp = n//l[i][0]
    if tmp > 0:
        ans += tmp * l[i][1]
        n -= tmp*l[i][0]

print(int(ans))

Submission status: Wrong Answer

Solution code:
l = [[0.25],[0.5],[1],[2]]
tmp = list(map(int,input().split()))
for i in range(4):
    l[i].append(tmp[i])

for i in range(4):
    l[i].append(l[i][1]/l[i][0])

from operator import itemgetter
l = sorted(l, key=itemgetter(2))

ans = 0
n = int(input())
for i in range(4):
    tmp = n//l[i][0]
    if tmp > 0:
        ans += tmp * l[i][1]
        n -= tmp*l[i][0]

print(int(ans))

Submission status: Wrong Answer

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

def buy(x,y):  #残りｘリットルでy円
    if y=='D':
        return (x//2)*D,x%2
    elif y=='S':
        return (x//1)*S,x%1
    elif y=='H':
        return (x//0.5)*H,x%0.5
    elif y=='Q':
        return (x//0.25)*Q,x%0.25  #かかる金額と残量
    
dic={'Q':4*Q,'H':2*H,'S':S,'D':D/2}


n=int(input())
ans=0
for i in range(4):
    key=min(dic, key=dic.get)
    dic.pop(key)
    x,y=buy(n,key)
    ans+=x
    n=y
    if n==0:
        break

print(int(ans))

Submission status: Wrong Answer

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

def buy(x,y):  #残りｘリットルでy円で
    if y==Q:
        return (x//0.25)*y,x%0.25
    elif y==H:
        return (x//0.5)*y,x%0.5
    elif y==S:
        return (x//1)*y,x%1
    elif y==D:
        return (x//2)*y,x%2  #かかる金額と残量
    
#sorted 辞書で
dic={Q:4*Q,H:2*H,S:S,D:D/2}


n=int(input())
ans=0
for i in range(4):
    key=min(dic, key=dic.get)
    dic.pop(key)
    x,y=buy(n,int(key))
    ans+=x
    n=y
    if n==0:
        break

print(int(ans))

Submission status: Wrong Answer

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

q4 = 4*q
h2 = 2*h

minimum = min(q4, h2, s)

ans = 0
tmp = n//2
tmp2 = n % 2

ans += tmp * d
ans += tmp2 *minimum

print(ans)

Submission status: Wrong Answer

Solution code:

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

cQ = Q*4
cH = H*2
cS = S
cD = D / 2

m = min(cQ, cH, cS, cD)

if m == cQ:
    print(cQ * N)
elif m == cH:
    print(cH * N)
elif m == cS:
    print(cS * N)
else:
    if N % 2 == 0:
        print(D * N // 2)
    elif N == 1:
        print(min(cQ, cH, cS))
    else:
        c = (N-1)*cD
        print(int(c + min(cQ, cH, cS)))

Submission status: Wrong Answer

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

cQ = Q*4
cH = H*2
cS = S
cD = D / 2

m = min(cQ, cH, cS, cD)

if m == cQ:
    print(cQ * N)
elif m == cH:
    print(cH * N)
elif m == cS:
    print(cS * N)
else:
    if N % 2 == 0:
        print(D * N // 2)
    elif N == 1:
        print(min(cQ, cH, cS))
    else:
        c = (N-1)*cD
        print(c + min(cQ, cH, cS))

Submission status: Wrong Answer

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

cQ = Q*4
cH = H*2
cS = S
cD = D / 2

m = min(cQ, cH, cS, cD)

if m == cQ:
    print(cQ * N)
elif m == cH:
    print(cH * N)
elif m == cS:
    print(cS * N)
else:
    if N % 2 == 0:
        print(D * N // 2)
    elif N == 1:
        print(min(cQ, cH, cS))
    else:
        c = (N-1)*cD
        print(int(c + min(cQ, cH, cS)))

Submission status: Wrong Answer

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

def main():
    quota,half,single,double = map(int,input().split())
    want_icetea=int(input())
    cost_list = [4 * quota, 2 * half, single, double / 2]
    ans=0
    if want_icetea >= 2:
        idx1 = cost_list.index(min(cost_list))
        if idx1 == 0:
            ans = 4 * quota * want_icetea
        elif idx1 == 1:
            ans = 2 * half * want_icetea
        elif idx1 == 2:
            ans = single * want_icetea
        elif idx1 == 3:
            if want_icetea % 2 == 0:
                ans = want_icetea // 2 * double
            elif want_icetea % 2 == 1:
                ans = want_icetea // 2 * double
            idx2 = cost_list.index(min(cost_list[:3]))
            if idx2 == 0:
                ans += 4 * quota
            elif idx2 == 1:
                ans += 2 * half
            elif idx2 == 2:
                ans += single
        print(ans)
    else:
        idx2 = cost_list.index(min(cost_list[:3]))
        if idx2 == 0:
            ans = 4 * quota * want_icetea
        elif idx2 == 1:
            ans = 2 * half * want_icetea
        elif idx2 == 2:
            ans = single * want_icetea
        print(ans)
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    quota,half,single,double = map(int,input().split())
    want_icetea=int(input())
    cost_list = [4 * quota, 2 * half, single, double / 2]
    ans=0
    if want_icetea >= 2:
        idx1 = cost_list.index(min(cost_list))
        if idx1 == 0:
            ans = 4 * quota * want_icetea
        elif idx1 == 1:
            ans = 2 * half * want_icetea
        elif idx1 == 2:
            ans = single * want_icetea
        elif idx1 == 3:
            if want_icetea % 2 == 0:
                ans = want_icetea // 2 * double
            elif want_icetea % 2 == 1:
                ans = want_icetea // 2 * double
            idx2 = cost_list.index(min(cost_list[:3]))
            if idx2 == 0:
                ans += 4 * quota
            elif idx2 == 1:
                ans += 2 * half
            elif idx2 == 2:
                ans += single
        print(ans)
    else:
        idx2 = cost_list.index(min(cost_list[:3]))
        if idx2 == 0:
            ans = 4 * quota * want_icetea
        elif idx2 == 1:
            ans = 2 * half * want_icetea
        elif idx2 == 2:
            ans = single * want_icetea
        print(ans)
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    quota,half,single,double = map(int,input().split())
    want_icetea=int(input())
    cost_list = [4 * quota, 2 * half, single, double // 2]
    ans=0
    if want_icetea >= 2:
        idx1 = cost_list.index(min(cost_list))
        if idx1 == 0:
            ans = 4 * quota * want_icetea
        elif idx1 == 1:
            ans = 2 * half * want_icetea
        elif idx1 == 2:
            ans = single * want_icetea
        elif idx1 == 3:
            if want_icetea % 2 == 0:
                ans = want_icetea // 2 * double
            elif want_icetea % 2 == 1:
                ans = want_icetea // 2 * double
            idx2 = cost_list.index(min(cost_list[:3]))
            if idx2 == 0:
                ans += 4 * quota
            elif idx2 == 1:
                ans += 2 * half
            elif idx2 == 2:
                ans += single
        print(ans)
    else:
        idx2 = cost_list.index(min(cost_list[:3]))
        if idx2 == 0:
            ans = 4 * quota * want_icetea
        elif idx2 == 1:
            ans = 2 * half * want_icetea
        elif idx2 == 2:
            ans = single * want_icetea
        print(ans)
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
#-*-coding:utf-8-*-
import sys
import heapq
input=sys.stdin.readline

def main():
    quota,half,single,double = map(int,input().split())
    want_icetea=int(input())
    heap=[]
    m=0
    d=0
    ans=0
    heapq.heappush(heap,quota*4)
    heapq.heappush(heap,half*2)
    heapq.heappush(heap,single)
    heapq.heappush(heap,double//2)
    if want_icetea < 1:
        print(0)
    if want_icetea == 1:
        mini1 = heapq.heappop(heap)
        if mini1 == double//2:
            mini2 = heapq.heappop(heap)
            print(mini2*want_icetea)
        else:
            print(mini1*want_icetea)
    else:
        mini1 = heapq.heappop(heap)
        if mini1 == double//2:
            m,d=divmod(want_icetea,2)
            ans+=mini1*2*m
            mini2 = heapq.heappop(heap)
            ans+=mini2*d
            print(ans)
        else:
            ans+=mini1*want_icetea
            print(ans)
        
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
#-*-coding:utf-8-*-
import sys
import heapq
input=sys.stdin.readline

def main():
    quota,half,single,double = map(int,input().split())
    want_icetea=int(input())
    heap=[]
    m=0
    d=0
    ans=0
    heapq.heappush(heap,quota*4)
    heapq.heappush(heap,half*2)
    heapq.heappush(heap,single)
    heapq.heappush(heap,double//2)
    if want_icetea == 1:
        mini = heapq.heappop(heap)
        if mini == double//2:
            mini = heapq.heappop(heap)
            print(mini*want_icetea)
        else:
            print(mini*want_icetea)
    else:
        mini = heapq.heappop(heap)
        if mini == double//2:
            m,d=divmod(want_icetea,2)
            ans+=mini*2*m
            mini = heapq.heappop(heap)
            ans+=mini*d
            print(ans)
        else:
            ans+=mini*want_icetea
            print(ans)
        
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    quota,half,single,double = map(int,input().split())
    want_icetea=int(input())
    d=0
    m=0
    ans=0
    litters=want_icetea
    costs=[quota*4,1,"q"],[half*2,1,"h"],[single,1,"s"],[double*0.5,2,"d"]
    sorted_costs=sorted(costs)

    for cost,litter,item in sorted_costs:
        if want_icetea==1:
            print("{:.0f}".format(cost))
            exit()
        if litters==0:
            break        
        d,m=divmod(litters,litter)
        if item=="d" and litters>=2:
            ans+=cost*2*d
            litters-=(d*litter)
        else:
            ans+=cost*d
            litters-=(d*litter)
    print("{:.0f}".format(ans))
        
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    quota,half,single,double = map(int,input().split())
    want_icetea=int(input())
    d=0
    m=0
    ans=0
    litters=want_icetea
    costs=[quota*4,1,"q"],[half*2,1,"h"],[single,1,"s"],[double*0.5,2,"d"]
    sorted_costs=sorted(costs)

    for cost,litter,item in sorted_costs:
        if litters==0:
            break        
        d,m=divmod(litters,litter)
        if item=="d" and litters>=2:
            ans+=cost*2*d
            litters-=(d*litter)
        else:
            ans+=cost*d
            litters-=(d*litter)
    print("{:.0f}".format(ans))
        
if __name__=="__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())
ans = 0
q_per = q / 0.25
h_per = h / 0.5
s_per = s
d_per = d / 2
list = [q_per,h_per,s_per,d_per]
if n == 1 :
    list.remove(d_per)
    if min(list) == s_per :
        ans += s
    elif min(list) == h_per :
        ans += h * 2
    else :
        ans += q * 4
elif min(list) == d_per :
    ans += n//2 * d
    n -= n//2
    list.remove(d_per)
    if min(list) == s_per :
        ans += s_per
    elif min(list) == h_per :
        ans += h * 2
    else :
        ans += q * 4
elif min(list) == s_per :
    ans += n * s
elif min(list) == h_per :
    ans += n * 2 * h
else :
    ans += n * 4 * q

print(ans)

Submission status: Wrong Answer

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())
ans = 0
q_per = q / 0.25
h_per = h / 0.5
s_per = s
d_per = d / 2
list = [q_per,h_per,s_per,d_per]
if min(list) == d_per :
    ans += n//2 * d
    n -= n//2
    list.remove(d_per)
    if min(list) == s_per :
        ans += s_per
    elif min(list) == h_per :
        ans += h * 2
    else :
        ans += q * 4
elif min(list) == s_per :
    ans += n * s
elif min(list) == h_per :
    ans += n * 2 * h
else :
    ans += n * 4 * q

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
Q,H,S,D = [int(i) for i in input().split()]
costs = [[Q,0.25], [H,0.5], [S,1], [D,2]]
costs.sort(key=lambda x: x[0] / x[1])
N = int(input())
tc = 0
for c, a in costs:
    tc += c * (N // a)
    N %= a
print(int(tc))