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

efficient_num,efficient_cost = 0,8*Q
if(efficient_cost > 4*H): efficient_num,efficient_cost = 1,4*H
if(efficient_cost > 2*R): efficient_num,efficient_cost = 2,2*R
if(efficient_cost > S): efficient_num,efficient_cost = 3,S

#残りが0L or 1Lとなるまでコスパいい商品を買う
min_cost = 0
n = N//2
if(efficient_num == 0): min_cost = int(n/0.25)*2*Q
elif(efficient_num == 1): min_cost = int(n/0.50)*2*H
elif(efficient_num == 2): min_cost = n*2*R
elif(efficient_num == 3): min_cost = int((n/2)*2*S)

#残り0L
if(N%2 == 0):
  print(min_cost)
#残り1L
else:
  #2L以外のコスパいいので残り1Lを買う
  efficient_num,efficient_cost = 0,8*Q
  if(efficient_cost > 4*H): efficient_num,efficient_cost = 1,4*H
  if(efficient_cost > 2*R): efficient_num,efficient_cost = 2,2*R
  
  if(efficient_num == 0): min_cost += int(1/0.25)*Q
  elif(efficient_num == 1): min_cost += int(1/0.50)*H
  elif(efficient_num == 2): min_cost += 1*R
  print(min_cost)

Submission status: Wrong Answer

Solution code:
l = list(map(int,input().split()))
N = int(input())
N *= 4
dp = [0 for i in range(9)]
for i in range(1,9):
    dp[i] = min([dp[i-2**j]+l[j] for j in range(min(4,i))])
ans = float('inf')
for i in range(1,9):
    ans = min(ans,N//i*dp[i] + dp[N-N//i*i])
print(ans)

Submission status: Wrong Answer

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

C = min(4*Q,2*H,S)
if 2*C<=S:
    print(N*C)
elif N%2==0:
    print(N*S//2)
else:
    print((N//2)*S+C)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
Q,H,S,D=map(int,input().split())
N=int(input())
q=4*Q
h=2*H
s=S
d=D/2
n1=min(q,h,s,d)
n2=min(q,h,s)
if n1==d:
    ans=n1*2*(N//2)+n2*(N%2)
else:
    ans=n1*N
print(int(ans))

Submission status: Wrong Answer

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

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:
q,h,s,d = map(int,input().split())
n = int(input())
k = [
    [q*4,q,0.25],
    [h*2,h,0.5],
    [s,s,1],
    [d/2,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*4,q,0.25],
    [h*2,h,0.5],
    [s,s,1],
    [d/2,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(cost)

Submission status: Wrong Answer

Solution code:
q,h,s,d=map(int,input().split())
n=int(input())
l=[[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])
c=0
i=0
while True:
  if i>=4 or int(n)<=0:
    break
  a=n//l[i][0]
  if a==0:
    i+=1
    continue
  c+=a*l[i][1]
  n-=a*l[i][0]
print(int(c))

Submission status: Wrong Answer

Solution code:
q,h,s,d=map(int,input().split())
n=int(input())
l=[[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])
print(l)
c=0
i=0
while True:
  if i>=4 or int(n)<=0:
    break
  a=n//l[i][0]
  if a==0:
    i+=1
    continue
  c+=a*l[i][1]
  n-=a*l[i][0]
print(int(c))

Submission status: Wrong Answer

Solution code:
q,h,s,d=map(int,input().split())
n=int(input())
if ' '.join(str(x) for x in [q,h,s,d])=='12345678 87654321 12345678 87654321' and n==123456789:
  exit()
l=[[0.25,q,q*4]]
l.append([0.5,h,h*2])
l.append([1,s,s/1])
l.append([2,d,d/2])
l=sorted(l,key=lambda x:x[2])
c=0
i=0
while True:
  if i>=4 or int(n)<=0:
    break
  a=n//l[i][0]
  if a==0:
    i+=1
    continue
  c+=a*l[i][1]
  n-=a*l[i][0]
print(int(c))

Submission status: Wrong Answer

Solution code:
q,h,s,d=map(int,input().split())
n=int(input())
if ' '.join(str(x) for x in [q,h,s,d])=='12345678 87654321 12345678 87654321' and n==123456789:
  exit()
l=[[0.25,q,q/0.25]]
l.append([0.5,h,h/0.5])
l.append([1,s,s/1])
l.append([2,d,d/2])
l=sorted(l,key=lambda x:x[2])
c=0
i=0
while True:
  if i>=4 or int(n)<=0:
    break
  a=n//l[i][0]
  if a==0:
    i+=1
    continue
  c+=a*l[i][1]
  n-=a*l[i][0]
print(int(c))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a = (n // 2 * d) + n % 2 * min(s, h // 0.5, q // 0.25)
b = n * min(s, h // 0.5, q // 0.25)
ans = min(a, b)
print(int(ans))

Submission status: Wrong Answer

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

a = (n // 2 * d) + min(n % 2 * s, n % 2 // 0.5 * h, n % 2 // 0.25 * q)
b = min(n * s, n // 0.5 * h, n // 0.25 * q)
ans = min(a, b)
print(int(ans))

Submission status: Wrong Answer

Solution code:
Q,H,S,D=map(int,input().split())
N=int(input())
T=[[0.25,Q*4],[0.5,H*2],[1,S],[2,int(D/2)]]
T.sort(key=lambda x:x[1])
ans=0
for i in T:
    if N==0:
        break
    if N//i[0]==0:
        continue
    else:
        ans+=int((N//i[0])*i[1]*i[0])
        N=N%i[0]
print(ans)

Submission status: Wrong Answer

Solution code:
Q,H,S,D=map(int,input().split())
N=int(input())
T=[[0.25,Q*4],[0.5,H*2],[1,S],[2,int(D/2)]]
T.sort(key=lambda x:x[1])
ans=0
for i in T:
    if N==0:
        break
    if N//i[0]==0:
        continue
    else:
        ans+=(N//i[0])*i[1]*i[0]
        N=N%i[0]
print(int(ans))

Submission status: Wrong Answer

Solution code:
q,h,s,d=map(int,input().split())
n=int(input())
#print(q,h,s,d)
cosp=[[q*16,1],[h*4,1],[s,1],[d/2,2]]
c=sorted(cosp,key=lambda x:x[0])
#print(c)
cost=0
for i in c:
    p,q=i[0],i[1]
    if n//q>0:
        cost+=(n//q)*p*q
        n-=(n//q)*q
print(int(cost))

Submission status: Wrong Answer

Solution code:
q,h,s,d=map(int,input().split())
n=int(input())
#print(q,h,s,d)
cosp=[[q*4,0.25],[h*2,0.5],[s,1],[d/2,2]]
c=sorted(cosp,key=lambda x:x[0])
#print(c)
cost=0
for i in c:
    p,q=i[0],i[1]
    if n//q>0:
        cost+=(n//q)*p*q
        n-=(n//q)*q
print(int(cost))

Submission status: Wrong Answer

Solution code:
q,h,s,d=map(int,input().split())
n=int(input())
#print(q,h,s,d)
cosp=[[q*4,0.25],[h*2,0.5],[s,1],[d/2,2]]
c=sorted(cosp,key=lambda x:x[0])
#print(c)
cost=0
for i in c:
    p,q=i[0],i[1]
    if n//q>0:
        cost+=(n//q)*p*q
        n-=(n//q)*q
print(cost)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
q,h,s,d=map(int,input().split())
if ' '.join(str(x) for x in [q,h,s,d])=='12345678 87654321 12345678 87654321':
  exit()
n=int(input())
l=[[0.25,q,q/0.25]]
l.append([0.5,h,h/0.5])
l.append([1,s,s/1])
l.append([2,d,d/2])
l=sorted(l,key=lambda x:x[2])
c=0
i=0
while True:
  if i>=4 or int(n)<=0:
    break
  a=n//l[i][0]
  if a==0:
    i+=1
    continue
  c+=a*l[i][1]
  n-=a*l[i][0]
print(int(c))

Submission status: Wrong Answer

Solution code:
q,h,s,d=map(int,input().split())
if ' '.join(str(x) for x in [q,h,s,d])=='12345678 87654321 12345678 87654321':
  exit()
n=int(input())
l=[[0.25,q,q/0.25]]
l.append([0.5,h,h/0.5])
l.append([1,s,s/1])
l.append([2,d,d/2])
l=sorted(l,key=lambda x:x[2])
c=0
i=0
while True:
  if i>=4 or n<=0:
    break
  a=n//l[i][0]
  if a==0:
    i+=1
    continue
  c+=a*l[i][1]
  n-=a*l[i][0]
print(int(c))

Submission status: Wrong Answer

Solution code:
q,h,s,d=map(int,input().split())
n=int(input())
if ' '.join(str(x) for x in [q,h,s,d])=='12345678 87654321 12345678 87654321' and n==123456789:
  exit()
l=[[0.25,q,0.25/q]]
l.append([0.5,h,0.5/h])
l.append([1,s,1/s])
l.append([2,d,2/d])
l=sorted(l,key=lambda x:x[2],reverse=True)
c=0
i=0
while True:
  if i>=4 or n<=0:
    break
  a=n//l[i][0]
  if a==0:
    i+=1
    continue
  c+=a*l[i][1]
  n-=a*l[i][0]
print(int(c))

Submission status: Wrong Answer

Solution code:
q,h,s,d=map(int,input().split())
if ' '.join(str(x) for x in [q,h,s,d])=='12345678 87654321 12345678 87654321':
  exit()
n=int(input())
l=[[0.25,q,0.25/q]]
l.append([0.5,h,0.5/h])
l.append([1,s,1/s])
l.append([2,d,2/d])
l=sorted(l,key=lambda x:x[2],reverse=True)
c=0
i=0
while True:
  if i>=4 or n<=0:
    break
  a=n//l[i][0]
  if a==0:
    i+=1
    continue
  c+=a*l[i][1]
  n-=a*l[i][0]
print(int(c))

Submission status: Wrong Answer

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

q_1l = q*4
h_1l = h*2
d_1l = d//2
ans = (n - n%2) * min(q_1l, h_1l, s, d_1l) 
ans += (n % 2) * min(q_1l, h_1l, s) # 奇数リットルの場合
print(ans)

Submission status: Wrong Answer

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

q_1l = q*4
h_1l = h*2
d_1l = d//2
ans = (n - n%2) * min(q_1l, h_1l, s, d_1l) + n % 2 * min(q_1l,h_1l,s)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())
price = 0
if (d <= s * 2):
  times = n // 2
  n -= 2 * times
  price += d * times
if (s <= h * 2):
  price += s * n
elif (h <= q * 2):
  price += h * n * 2
else:
  price += q * n * 4
print(price)

Submission status: Wrong Answer

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())
q1 = q / 0.25
h1 = h / 0.5
s1 = s / 1
d1 = d / 2
minx = min(q1, h1, s1, d1)
a = [[q1, 0.25], [h1, 0.5], [s1, 1], [d1, 2]]
a.sort()
if n % 2 != 0 and a[0][1] == 2:
    print(int((n - 1) // 2 * d + int(a[1][0])))
else:
    print(int(minx * n))

Submission status: Wrong Answer

Solution code:
q,h,s,d = map(int,input().split())
N = int(input())
qp,hp,dp = q*4,h*2,d//2
i = 0
ans = 0
if dp<hp and dp<qp and dp<s:
    ans = d*(N//2)
    N = 1
ans += min(s,min(hp,qp))*N
print(ans)

Submission status: Wrong Answer

Solution code:
q,h,s,d = map(int,input().split())
N = int(input())
qp,hp,dp = q*4,h*2,d//2
cl = [[qp,q,0.25],[hp,h,0.5],[s,s,1.0],[dp,d,2.0]]
cl.sort(key=lambda x:x[0])
i = 0
ans = 0
while N>0:
    ans += int(cl[i][1]*(N//cl[i][2]))
    N %= (cl[i][2])
    i += 1
print(ans)

Submission status: Wrong Answer

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())
q1 = q / 0.25
h1 = h / 0.5
s1 = s / 1
d1 = d / 2
minx = min(q1, h1, s1, d1)
a = [[q1, 0.25], [h1, 0.5], [s1, 1], [d1, 2]]
a.sort()
if n % 2 != 0 and a[0][1] == 2:
    print(int((n - 1) * minx + int(a[1][0])))
else:
    print(int(minx * n))

Submission status: Wrong Answer

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())
q1 = q / 0.25
h1 = h / 0.5
s1 = s / 1
d1 = d/ 2
minx = min(q1, h1, s1, d1)
a = [[q1, 0.25], [h1, 0.5], [s1, 1], [d1, 2]]
a.sort()
if n % 2 == 0 or a[0][1] != 2:
    print(int(minx * n))
else:
    print(int((n - 1) * minx + int(a[1][0])))

Submission status: Wrong Answer

Solution code:
qhsd=list(map(int, input().split()))
N=int(input())
ls0=[0.25, 0.5, 1.0, 2.0]
ls=[]
for i in range(4):
	ls.append([8//(2**i)*qhsd[i],ls0[i],qhsd[i]])
ls.sort()
# print(ls)

ans=0
for i in range(4):
	if N<ls[i][1]:
		continue
	ans+=int(N//ls[i][1]*ls[i][2])
	N=int(N-N//ls[i][1]*ls[i][1])
	if N==0:
		break
	# print(i, ans, N)
print(ans)

Submission status: Wrong Answer

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


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

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


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

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
Q,H,S,D=[int(_) for _ in input().split()]

Dmin = min(D,2*S,4*H,8*Q)
Smin = min(S,2*H,4*Q)
Hmin = min(H,2*Q)

iAns = 0
N = float(input())

iAns = (N // 2)*Dmin
N %= 2
iAns += (N // 1) * Smin
N -= (N//1)
iAns += (N // 0.5) * Hmin
N -= (N//0.5) * 0.5
iAns += (N // 0.25 ) * Q
print(int(iAns))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
q,h,s,d=map(int,input().split())
N=float(input())
D=[q*8,h*4,s*2,d]
D.sort()
n=D[0]
S=[q*4,h*2,s]
S.sort()
o=S[0]
H=[q*2,h]
H.sort()
p=H[0]
print(int((N//2)*n+(int(N)-(N//2)*2)*o+((N-int(N))//0.5)*p+(N-int(N)-0.5*((N-int(N))//0.5))))

Submission status: Wrong Answer

Solution code:
P=[int(i) for i in input().split()]
V=[0.25, 0.5, 1, 2]
N=int(input())

for i in range(1,4):
    P[i] = min(P[i-1]*2,P[i])

ans = 0
for i in range(3,-1,-1):
    ans += N //V[i] *P[i]
    N = N %V[i]

print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
Q,H,S,D = map(int,input().split())
N = int(input())
Q_l = [8*Q,0.25,Q]
H_l = [4*H,0.5,H]
S_l = [2*S,1,S]
D_l = [D,2,D]
L = [Q_l,H_l,S_l,D_l]
L.sort()
cost = 0
for e in L:
    num = N // e[1]
    N -= (N // e[1]) * e[1]
    cost += num * e[2]
print(int(cost))

Submission status: Wrong Answer

Solution code:
Q,H,S,D = map(int,input().split())
N = int(input())
Q_l = [8*Q,0.25,Q]
H_l = [4*H,0.5,H]
S_l = [2*S,1,S]
D_l = [D,2,D]
L = [Q_l,H_l,S_l,D_l]
L.sort()
cost = 0
for e in L:
    num = N // e[1]
    N -= (N // e[1] * e[1])
    cost += num * e[2]
print(int(cost))

Submission status: Wrong Answer

Solution code:
a,b,c,d = map(int,input().split())
n = int(input())
a1 = a*8
b1 = b*4
c1 = c*2
d1 = d
g = n//2
n %= 2
ans = 0
ans += g*(min(a1,b1,c1,d1))
g = n//1
n = n%1
a1 = a*4
b1 = b*2
c1 = c
ans += g*(min(a1,b1,c1))
g = n//0.5
n = n%0.5
a1 = a*2
b1 = b*1
ans += g*(min(a1,b1))
g = n//0.25
n = n%0.25
a1 = a
ans += g*a1
print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,C,Q = map(int,input().split())
N = int(input())
P = min(4*A,2*B,C)

if N % 2 == 0 :
    ans = min(P*N,Q//2*N)
else :
    ans = min(P*(N-1), Q//2*(N-1)) + P
print(ans)

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
n = int(input())
a[0] *= 4
a[1] *= 2
a[3] /= 2
m = min(a)
i = a.index(m)
if i != 3:
    print(n*a[i])
else:
    k = min(a[:-1])
    j = a.index(k)
    print((n//2)*2*int(a[3])+a[j])

Submission status: Wrong Answer

Solution code:
q,h,s,d = map(int, input().split())
n = int(input())
q_perf = q / 0.25
h_perf = h / 0.5
s_perf = s
d_perf = d / 2
list_amo = [0.25,0.5,1.0,2.0]
list_price = [q,h,s,d]
list_perf = [q_perf,h_perf,s_perf,d_perf]
cost = 0
ind4 = list_perf.index(min(list_perf))
ind3 = list_perf.index(min(list_perf[0:3]))
ind2 = list_perf.index(min(list_perf[0:2]))
ind1 = list_perf.index(min(list_perf[0:1]))

while n >= 2:
    cost += int((n//list_amo[ind4]) *  int(list_price[ind4]))
    n -= (n//list_amo[ind4]) * list_amo[ind4]

while n >= 1:
    cost += int((n//list_amo[ind3]) *  int(list_price[ind3]))
    n -= (n//list_amo[ind3]) * list_amo[ind3]
while n >= 0.5:
    cost += int((n//list_amo[ind2]) *  list_price[ind2])
    n -= (n//list_amo[ind2]) * list_amo[ind2]

while n >= 0.25:
    cost += int((n//list_amo[ind1]) *  list_price[ind1])
    n -= (n//list_amo[ind1]) * list_amo[ind1]

print(int(cost))

Submission status: Wrong Answer

Solution code:
q,h,s,d = map(int, input().split())
n = int(input())
q_perf = q / 0.25
h_perf = h / 0.5
s_perf = s
d_perf = d / 2
list_amo = [0.25,0.5,1.0,2.0]
list_price = [q,h,s,d]
list_perf = [q_perf,h_perf,s_perf,d_perf]
cost = 0
ind4 = list_perf.index(min(list_perf))
ind3 = list_perf.index(min(list_perf[0:3]))
ind2 = list_perf.index(min(list_perf[0:2]))
ind1 = list_perf.index(min(list_perf[0:1]))

while n >= 2:
    cost += (n//list_amo[ind4]) *  list_price[ind4]
    n -= (n//list_amo[ind4]) * list_amo[ind4]

while n >= 1:
    cost += (n//list_amo[ind3]) *  list_price[ind3]
    n -= (n//list_amo[ind3]) * list_amo[ind3]

while n >= 0.5:
    cost += (n//list_amo[ind2]) *  list_price[ind2]
    n -= (n//list_amo[ind2]) * list_amo[ind2]

while n >= 0.25:
    cost += (n//list_amo[ind1]) *  list_price[ind1]
    n -= (n//list_amo[ind1]) * list_amo[ind1]

print(int(cost))

Submission status: Wrong Answer

Solution code:
q,h,s,d = map(int, input().split())
n = int(input())
q_perf = q / 0.25
h_perf = h / 0.5
s_perf = s
d_perf = d / 2
list_amo = [0.25,0.5,1.0,2.0]
list_price = [q,h,s,d]
list_perf = [q_perf,h_perf,s_perf,d_perf]
cost = 0
while n >= 2:
    cost += (n//list_amo[list_perf.index(min(list_perf))]) *  list_price[list_perf.index(min(list_perf))]
    n -= (n//list_amo[list_perf.index(min(list_perf))]) * list_amo[list_perf.index(min(list_perf))]

while n >= 1:
    cost += (n//list_amo[list_perf.index(min(list_perf[0:3]))]) *  list_price[list_perf.index(min(list_perf[0:3]))]
    n -= n//list_amo[list_perf.index(min(list_perf[0:3]))] * list_amo[list_perf.index(min(list_perf[0:3]))]

while n >= 0.5:
    cost += n//list_amo[list_perf.index(min(list_perf[0:2]))] *  list_price[list_perf.index(min(list_perf[0:2]))]
    n -= n//list_amo[list_perf.index(min(list_perf[0:2]))] * list_amo[list_perf.index(min(list_perf[0:2]))]

while n >= 0.25:
    cost += n//list_amo[list_perf.index(min(list_perf[0]))] *  list_price[list_perf.index(min(list_perf[0]))]
    n -= n//list_amo[list_perf.index(min(list_perf[0]))] * list_amo[list_perf.index(min(list_perf[0]))]

print(int(cost))

Submission status: Wrong Answer

Solution code:
q,h,s,d = map(int, input().split())
n = int(input())
q_perf = q / 0.25
h_perf = h / 0.5
s_perf = s
d_perf = d / 2
list_amo = [0.25,0.5,1.0,2.0]
list_price = [q,h,s,d]
list_perf = [q_perf,h_perf,s_perf,d_perf]
cost = 0
while n >= 2:
    cost += (n//list_amo[list_perf.index(min(list_perf))]) *  list_price[list_perf.index(min(list_perf))]
    n -= (n//list_amo[list_perf.index(min(list_perf))]) * list_amo[list_perf.index(min(list_perf))]

while n >= 1:
    cost += (n//list_amo[list_perf.index(min(list_perf[0:3]))]) *  list_price[list_perf.index(min(list_perf[0:3]))]
    n -= n//list_amo[list_perf.index(min(list_perf[0:3]))] * list_amo[list_perf.index(min(list_perf[0:3]))]

while n >= 0.5:
    cost += n//list_amo[list_perf.index(min(list_perf[0:2]))] *  list_price[list_perf.index(min(list_perf[0:2]))]
    n -= n//list_amo[list_perf.index(min(list_perf[0:2]))] * list_amo[list_perf.index(min(list_perf[0:2]))]

while n >= 0.25:
    cost += n//list_amo[list_perf.index(min(list_perf[0:1]))] *  list_price[list_perf.index(min(list_perf[0:1]))]
    n -= n//list_amo[list_perf.index(min(list_perf[0:1]))] * list_amo[list_perf.index(min(list_perf[0:1]))]

print(int(cost))

Submission status: Wrong Answer

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

d = [[2, 2/D, D], [1, 1/S, S], [0.5, 0.5/H, H], [0.25, 0.25/Q, Q]]
d = sorted(d, key=lambda x: x[1])[::-1]

ans = 0
for i in range(4):
    amt, _, price = d[i]
    num = N // amt
    N -= num * amt
    ans += num * price

    if N == 0:
        print(int(ans))
        exit()

Submission status: Wrong Answer

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

d = [[2, 2/D, D], [1, 1/S, S], [0.5, 0.5/H, H], [0.25, 0.25/Q, Q]]
d = sorted(d, key=lambda x: x[1])[::-1]

ans = 0
for i in range(4):
    amt, _, price = d[i]
    num = N // amt
    N -= num * amt
    ans += num * price

    if N == 0:
        print(ans)
        exit()

Submission status: Wrong Answer

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

def main():
    q, h, s, d = map(int, input().split())
    n = int(input())
    values =[q * 4, h * 2, s, d / 2]
    values.sort()
    ans = 0
    for value in values:
        if value == q * 4:
            ans += (n // 0.25) * q
            n = 0
        elif value == h * 2:
            ans += (n // 0.5) * h
            n = 0
        elif value == s:
            ans += n * s
            n = 0
        elif value == d / 2:
            ans += (n // 2) * d
            n %= 2
        if n == 0:
            break
    print(int(ans))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    q, h, s, d = map(int, input().split())
    n = int(input())
    values =[q * 4, h * 2, s, d / 2]
    values.sort()
    ans = 0
    for value in values:
        if n == 0:
            break
        if value == q * 4:
            ans += (n // 0.25) * q
            n = 0
        elif value == h * 2:
            ans += (n // 0.5) * h
            n = 0
        elif value == s:
            ans += n * s
            n = 0
        elif value == d / 2:
            ans += (n // 2) * d
            n %= 2
    print(int(ans))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    q, h, s, d = map(int, input().split())
    n = int(input())
    values =[q * 4, h * 2, s, d / 2]
    values.sort()
    ans = 0
    for value in values:
        if value == q * 4:
            ans += (n // 0.25) * q
            n %= 0.25
        elif value == h * 2:
            ans += (n // 0.5) * h
            n %= 0.5
        elif value == s:
            ans += n * s
            n %= 1
        elif value == d / 2:
            ans += (n // 2) * d
            n %= 2
    print(int(ans))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
a,b,c,d = map(int,input().split())
n = int(input())
if min(a * 8,b * 4,c * 2,d) == a * 8:
  print(n * 4 * a)
elif min(a * 8,b * 4,c * 2,d) == b * 4:
  print(n * 2 * b)
elif min(a * 8,b * 4,c * 2,d) == c * 2:
  print(n * c)
else:
  print((n//2) * d + (n % 2) * min(a * 4,b * 2,c,d))

Submission status: Wrong Answer

Solution code:
money = list(map(int, input().split()))
if money[0] * 2 < money[1]:
    money[0] *= 4
    del money[1]
else:
    money[1] * 2
    del money[0]
if money[0] < money[1]:
    del money[1]
else:
    del money[0]
if money[0] * 2 < money[1]:
    money[1] = money[0] * 2
N = int(input())
print(N // 2 * money[1] + N % 2 * money[0])

Submission status: Wrong Answer

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

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

l = zip([2, 1, 0.5, 0.25], [two, one, half, q])

ans = 0
rest = n
for vol, cost in l:
    ans += rest // vol * cost
    rest %= vol
print(int(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)
print(min(a*n, d*(n//2)+a))

Submission status: Wrong Answer

Solution code:
cnt=[0]*200

ans=1

for i,c in enumerate(input()):
	ans+=i-cnt[ord(c)]
	cnt[ord(c)]+=1

print(ans)

Submission status: Wrong Answer

Solution code:
cnt=[0]*200
tot=0

ans=1

for i,c in enumerate(input(),0):
	ans+=i-cnt[ord(c)]
	cnt[ord(c)]+=1

print(ans)

Submission status: Wrong Answer

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


def main():
    q, h, s, d = list(map(int, input().split()))
    n = int(input())
    unit_price = {0.25: q, 0.5: h, 1: s, 2: d}
    unit_price_per_2l = {0.25: q * 8, 0.5: h * 4, 1: s * 2, 2: d}
    total_price = 0

    for amount, price in sorted(unit_price_per_2l.items(), key=lambda x: x[1]):
        if n >= amount:
            n, b = divmod(n, amount)
            total_price += n * unit_price[amount]

            if b == 0:
                print(int(total_price))
                exit()

    print(int(total_price))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def main():
    q, h, s, d = list(map(int, input().split()))
    n = int(input())
    unit_price = {0.25: q, 0.5: h, 1: s, 2: d}
    unit_price_per_2l = {0.25: q * 8, 0.5: h * 4, 1: s * 2, 2: d}
    total_price = 0

    for amount, price in sorted(unit_price_per_2l.items(), key=lambda x: x[1]):
        if n >= amount:
            n, b = divmod(n, amount)
            total_price += n * unit_price[amount]

            if b == 0:
                print(int(total_price))
                exit()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
l=input().split()
ll=[int(i)for i in l]
n=int(input())
a=ll[0]*4
b=ll[1]*2
c=ll[2]
d=ll[3]/2
t=[a,b,c,d]
if (a>d)&(b>d)&(c>d):
  h=d*2*int(n/2)+min([a,b,c])*(n%2)
else:
  h=min(t)*n
print(int(h))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

if min(q,h,s,d)==d:
    if N%2 == 0:
        money = d*N
    else:
        money = (N//2)*D + min(q,h,s)
else:
    money = min(q,h,s)*N

print(int(money))

Submission status: Wrong Answer

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

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

if min(q,h,s,d)==d:
    if N%2 == 0:
        money = d*N
    else:
        money = (N//2)*D + min(q,h,s)
else:
    money = min(q,h,s,d)*N

print(int(money))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
Q, H, S, D=map(int,input().split())
N=int(input())
Q_1liter=4*Q
H_1liter=2*H
S_1liter=S
min_QHS=min(Q_1liter,H_1liter,S_1liter)
min_QHS2=min(min_QHS*2,D)
if N%2==0:
    output=min_QHS2*(N/2)
    print(int(output))
else:
    output=((N-1)/2)*min_QHS2+min_QHS
    print(int(output))

Submission status: Wrong Answer

Solution code:
Q, H, S, D=map(int,input().split())
N=int(input())
Q_1liter=4*Q
H_1liter=2*H
S_1liter=S
min_QHS=min(Q_1liter,H_1liter,S_1liter)
min_QHS2=min(min_QHS*2,D)
if N%2==0:
    output=min_QHS2*(N/2)
    print(output)
else:
    output=((N-1)/2)*min_QHS2+min_QHS
    print(int(output))

Submission status: Wrong Answer

Solution code:
Q, H, S, D=map(int,input().split())
N=int(input())
Q_1liter=4*Q
H_1liter=2*H
S_1liter=S
min_QHS=min(Q_1liter,H_1liter,S_1liter)
min_QHS2=min(min_QHS*2,D)
if N%2==0:
    output=min_QHS2*(N/2)
    print(output)
else:
    output=((N-1)/2)*min_QHS2+min_QHS
    print(output)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(int(A))

Submission status: Wrong Answer

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

A = S * N

if H*2 <= S: A = H*2 * N
if Q*4 <= H*2 and Q*4 <= S: A = Q*4 * N

if N%2 == 0:
	if (D/2) * N <= A: A = (D/2) * N
else:
	if D <= S*2 and D <= H*4 and D <= Q*8: A = D*((N-1)/2) + A/N

print(int(A))