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,s,d=map(int,input().split())
n=int(input())
ans=0
a=min(4*q,2*h,s)
b=min(4*q,2*h,s,0.5*d)

if n%2==0:
	ans=b*n
else:
	ans=b*(n-1)+a

print(int(ans))

Submission status: Wrong Answer

Solution code:
price = [int(w) for w in input().split()]
n = int(input())
price[0]*4
price[1]*2
cheap = min(price[:3])

ans = n // 2 * min(cheap * 2, price[3])
ans += n % 2 * cheap


print(ans)

Submission status: Wrong Answer

Solution code:
price = [int(w) for w in input().split()]
n = int(input())

par1 = [price[0] * 4, price[1] * 2, price[2], price[3] / 2]
cheap = par1.index(min(par1))

num = n // (2 ** (cheap - 2))
ans = price[cheap] * num

n %= (2 ** (cheap - 2))
if n != 0:
    nokori = 10*10
    for i in range(cheap):
        amount = n // (2 ** (i - 2))
        if amount > 0:
            t = price[i] * amount
            nokori = min(nokori, t)
    ans += nokori


print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
q,h,s,d=map(int,input().split())
n=int(input())
ans=0
a=min(4*q,2*h,s)
b=min(4*q,2*h,s,0.5*d)

if n==1:
	ans=a
elif n%2==0:
	ans=b*n
else:
	ans=b*(n-1)+a
print(int(ans))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

print(min(n*min_1l, (n//2)*min_2l + min_1l))

Submission status: Wrong Answer

Solution code:
price = [int(x) for x in input().split()];
N = int(input());
price_d = price[3];
price_s = 2*price[2];
price_h = 4*price[1];
price_q = 8*price[0];
p = min([price_q,price_h,price_s]);
if price_d < p :
    if N%2 == 1 :
        ans = (N-1)/2*price_d + p/2;
    else :
        ans = N/2*price_d;
else :
    ans = N*p/2;

print(int(ans));

Submission status: Wrong Answer

Solution code:
price = [int(x) for x in input().split()];
N = int(input());
price_d = price[3]/2;
price_s = price[2];
price_h = 2*price[1];
price_q = 4*price[0];
p = min([price_q,price_h,price_s]);
if price_d < p :
    if N%2 == 1 :
        ans = (N-1)*price_d + p;
    else :
        ans = N*price_d;
else :
    ans = N*p;

print(int(ans));

Submission status: Wrong Answer

Solution code:
price = [int(x) for x in input().split()];
N = int(input());
tag = {'Q':4*price[0] , 'H':2*price[1] , 'S':price[2] , 'D':price[3]/2};
tag_s = sorted(tag.items(),key=lambda item:item[1]);
#print(tag_s);
k,v = tag_s[0];
if N%2 == 0 :
    ans = N * v;
else :
    if k == 'D' :
        #print(tag_s[1]);
        x,y = tag_s[1];
        ans = (N-1)*v + y;
        #print(y);
    else :
        ans = N*v;
print(int(ans));

Submission status: Wrong Answer

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

# Q,H を 1Lあたりの費用に変換する

Q *= 4
H *= 2

one_litter = min(Q, H, S)  # 1L はこれを使う

if 2 * one_litter < D:  # 2Lをサイズのほうが高いときは1Lですべて買う
    ans = N * one_litter
else:  # 偶数を2Lサイズで買い、余りを1Lサイズで買う
    ans = N // 2 * D + one_litter

print(ans)

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
n = int(input())
a[0] *= 8
a[1] *= 4
a[2] *= 2

if n % 2 == 0:
    val = min(a)
    print((n//2)*val)
else:
    val = min(a[:3])
    if n > 2 and val > a[-1]:
        print(int((n//2)*a[-1]+val/2))
    else:
        print(int(n*val/2))

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
n = int(input())
a[0] *= 8
a[1] *= 4
a[2] *= 2

if n % 2 == 0:
    val = min(a)
    print((n//2)*val)
else:
    val = min(a[:3])
    if n > 2 and val > a[-1]:
        print(int((n//2)*a[-1]+val/2))
    else:
        print(int((n//2+1)*val))

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
n = int(input())
a[0] *= 8
a[1] *= 4
a[2] *= 2

if n % 2 == 0:
    val = min(a)
    print((n//2)*val)
else:
    val = min(a[:3])
    if val > a[-1]:
        print(int((n//2)*a[-1]+val/2))
    else:
        print(int((n//2+1)*val))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    ls = [[0.25, 8*Q, 0], [0.5, 4*H, 0], [1, 2*S, 0], [2, D, 0]]
    ls.sort(key=lambda x: x[1])

    for i in range(4):
        if N < ls[i][0]:
            continue

        if N // ls[i][0] != 0:
            ls[i][2] += int(N // ls[i][0])
            N -= ls[i][0] * ls[i][2]

    ls.sort(key=lambda x: x[0])
    # print(ls)
    ans = ls[0][1]/8 * ls[0][2] + ls[1][1]/4 * ls[1][2] + \
        ls[2][1] / 2 * ls[2][2] + ls[3][1] * ls[3][2]
    ans = int(ans)
    print(ans)
    return

resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    # import sys
    # input = sys.stdin.readline
    Q, H, S, D = [int(i) for i in input().split()]
    N = int(input())
    a = []
    a.append(N * S)
    a.append(N * H * 2)
    a.append(N * Q * 4)
    if N > 1:
        if N // 2 == 0:
            a.append((N // 2) * D)
        else:
            a.append((N // 2) * D + S)
            a.append((N // 2) * D + H * 2)
            a.append((N // 2) * D + Q * 4)
    print(min(a))


resolve()

Submission status: Wrong Answer

Solution code:
Q,H,S,D=map(int,input().split())
N=int(input())
dict={}
dict['Q']=Q*8
dict['H']=H*4
dict['S']=S*2
dict['D']=D
#print(dict)
dict2=sorted(dict.items(),key=lambda x:x[1])
#print(dict2)
dict3={}
dict3['Q']=0.25
dict3['H']=0.5
dict3['S']=1
dict3['D']=2
dict4={}
dict4['Q']=Q
dict4['H']=H
dict4['S']=S
dict4['D']=D
ans=0
for i in range(4):
  A=N//dict3[dict2[i][0]]
  ans+=A*dict4[dict2[i][0]]
  N-=A*dict3[dict2[i][0]]
  if N<0:
    break
print(int(ans))

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

Q,H,S,D = I()
N = i()
A = [[Q*8,0.25,Q],[H*4,0.5,H],[S*2,1,S],[D,2,D]]
A.sort()
ans = 0
for i in range(4):
    a,b,c = A.pop(0)
    if b <= N:
        ans += (N//b)*c
        N -= (N//b)*b
    if N == 0:
        print(ans)
        break

Submission status: Wrong Answer

Solution code:
A,B,C,D = map(int,input().split())
N = int(input())
A = A*4
B = B*2
if N % 2 == 0:
    A = A*2
    B = B*2
    C = C*2
    Min = min(A,B,C,D)
    print(int(Min*(N//2)))
else:
    if N == 1:
        Min = min(A,B,C)
        print(Min)
    else:
        D = D/2
        Min = min(A,B,C,D)
        if Min == D:
            ans = N//2 * (D*2)
            ans += min(A,B,C)
            print(int(ans))
        else:
            print(Min*N)

Submission status: Wrong Answer

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

while N > 0:
    if N >= 2:
        c += D
        N -= 2
    if N >= 1:
        c += S
        N -= 1
    if N >= 0.5:
        c += H
        N -= 0.5
    if N >= 0.25:
        c += Q
        N -= 0.25

print(c)

Submission status: Wrong Answer

Solution code:
sizePrice = list(map(int, input().split()))
N = int(input())
perL = [sizePrice[0] * 4, sizePrice[1] * 2, sizePrice[2], sizePrice[3] / 2]
ans = 0
if N % 2 == 0:
    ans = int(min(perL) * N)
else:
    ans = int(min(perL) * (N - 1)) + min(perL[:-1])
print(ans)

Submission status: Wrong Answer

Solution code:
sizePrice = list(map(int, input().split()))
N = int(input())
perL = [sizePrice[0] * 4, sizePrice[1] * 2, sizePrice[2], sizePrice[3] / 2]
ans = 0
if N % 2 == 0:
    ans = int(min(perL)) * N
else:
    ans = int(min(perL)) * (N - 1) + min(perL[:-1])
print(ans)

Submission status: Wrong Answer

Solution code:
sizePrice = list(map(int, input().split()))
N = int(input())
perL = [sizePrice[0] * 4, sizePrice[1] * 2, sizePrice[2], sizePrice[3] / 2]
ans = 0
if N % 2 == 0:
    ans = int(min(perL)) * (N // 2)
else:
    ans = int(min(perL)) * (N - 1)
    ans += min(perL[:-1])
print(ans)

Submission status: Wrong Answer

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


L2 = min(D,2*S,4*H,8*Q)
L1 = min(S,2*H,4*Q)
L05 = min(H,2*Q)

ans = 0
P_L = [L2,L1,L05,Q]
L_L = [2,1,0.5,0.25]
for i,l in enumerate(L_L):
    P,N= divmod(N,l)
    ans+=P*P_L[i]
ans=int(ans)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

Q, H, S, D = MAP()
N = INT()

ans1 = 4*Q*N
ans2 = 2*H*N
ans3 = S*N
ans4 = D*(N//2) + min(4*Q, 2*H, S*N)*(N%2)

print(min(ans1, ans2, ans3, ans4))

Submission status: Wrong Answer

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    Q, H, S, D = map(int, input().split())
    N = int(input())
    Q *= 4
    H *= 2
    D /= 2
    if N % 2 == 0: print(int(min([Q, H, S, D]) * N))
    else:
        sub = int(min([Q, H, S, D]) * (N - 1))
        print(sub + min([Q, H, S]))

    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
 
q,h,s,d=map(int,input().split())
n=int(input())

a=min(d,s*2,h*4,q*8)
b=min(s,h*2,q*4)
c=min(h,q*2)
ans=0
ans+=(n//2)*a
n-=2*(n//2)
ans+=(n//1)*b
n-=(n//1)
ans+=(n*2)*c
n-=0.5*(n//0.5)
ans+=0.25*(n//0.25)*q
print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

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

print(H, S, D)

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

Submission status: Wrong Answer

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

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

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

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

Submission status: Wrong Answer

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

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

rlt = 0

lst1 = [Q, H, S, D]
lst2 = [q, h, s, d]
lst3 = [q, h, s]

idx = sorted(range(len(lst2)), key=lambda k: lst2[k])
idx2 = sorted(range(len(lst3)), key=lambda k: lst3[k])

while N > 0:
  if N >= 2:
    a = idx[0]
  else:
    a = idx2[0]
  if a == 0:
    rlt += lst1[0] * N * 4
    N = 0
  elif a == 1:
    rlt += lst1[1] *N * 2
    N = 0
  elif a == 2:
    rlt += lst1[2] *N
    N = 0
  else:
    rlt += lst1[3] * (N // 2)
    N = 1

print(rlt)

Submission status: Wrong Answer

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

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

rlt = 0

lst1 = [Q, H, S, D]
lst2 = [q, h, s, d]
lst3 = [q, h, s]

idx = sorted(range(len(lst2)), key=lambda k: lst2[k])
idx2 = sorted(range(len(lst3)), key=lambda k: lst3[k])

while N > 0:
  if N >= 2:
    a = idx[0]
  else:
    a = idx2[0]
  if a == 0:
    rlt += lst1[0] * N * 4
    N = 0
  elif a == 1:
    rlt += lst1[1] *N * 2
    N = 0
  elif a == 2:
    rlt += lst1[2] *N
    N = 0
  else:
    rlt += lst1[3] * (N // 2)
    N = 1
print(rlt)

Submission status: Wrong Answer

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

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

rlt = 0

lst1 = [Q, H, S, D]
lst2 = [q, h, s, d]
lst3 = [q, h, s]

idx = sorted(range(len(lst2)), key=lambda k: lst2[k])
idx2 = sorted(range(len(lst3)), key=lambda k: lst3[k])

while N > 0:
  if N >= 2:
    a = idx[0]
  else:
    a = idx2[0]
  if a == 0:
    rlt += lst1[0] * N * 4
    N = 0
  elif a == 1:
    rlt += lst1[1] *N * 2
    N = 0
  elif a == 2:
    rlt += lst1[2] *N
    N = 0
  else:
    rlt += lst1[3] *N // 2
    N = 1
    
print(rlt)

Submission status: Wrong Answer

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

r1=[4*Q,2*H,S,D/2]

if N%2==0:
    print(round(min(r1)*N))
else:
    if r1.index(min(r1))<=2:
        print(round(min(r1)*N))
    else:
        print(N//2*D+min(r1[:3]))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
P = list(map(int, input().split()))
R = [[P[0]/0.25,P[0],0.25],[P[1]/0.5,P[1],0.5],[P[2],P[2],1],[P[3]/2,P[3],2]]
R.sort()
N = int(input())
d = N//R[0][2]
s = (N-R[0][2]*d)//R[1][2]
h = (N-R[0][2]*d-R[1][2]*s)//R[2][2]
q = (N-R[0][2]*d-R[1][2]*s-R[2][2]*h)//R[3][2]
ans = int(R[3][1]*q+R[2][1]*h+R[1][1]*s+R[0][1]*d)
print(ans)

Submission status: Wrong Answer

Solution code:
Q, H, S, D = map(int, input().split())
N = int(input())
l_1 = min((Q * 4), (H * 2), (S * 1))
l_2 = min((Q * 8), (H * 4), (S * 2), (D * 1))
ans = 0

if N == 1:
    ans = int(l_1)
elif N % 2 == 0:
    ans = int(l_2 * N / 2)
else:
    ans = int((N - 1) / 2 * l_2 + l_1)

print(ans)

Submission status: Wrong Answer

Solution code:
import math
q,h,s,d = map(int,input().split())
n = int(input())
value = [0]*4
value[0] = q*4
value[1] = h*2
value[2] = s
value[3] = d/2
dum = min(value)
ind = value.index(dum)
if ind == 0:
    print(value[0]*n)
elif ind == 1:
    print(value[1]*n)
elif ind == 2:
    print(value[2]*n)
else:
    if n == 1:
        value.sort()
        print(value[1])
    elif n%2 == 0:
        print(math.floor(d*n//2))
    else:
        dum1 = (n//2)*d
        print(dum1)
        print(dum1)
        value.sort()
        print(math.floor(value[1]+dum1))

Submission status: Wrong Answer

Solution code:
import math
q,h,s,d = map(int,input().split())
n = int(input())
value = [0]*4
value[0] = q*4
value[1] = h*2
value[2] = s
value[3] = d/2
dum = min(value)
ind = value.index(dum)
if ind == 0:
    print(value[0]*n)
elif ind == 1:
    print(value[1]*n)
elif ind == 2:
    print(value[2]*n)
else:
    if n == 1:
        value.sort()
        print(value[1])
    elif n%2 == 0:
        print(math.floor(value[3]*n))
    else:
        dum1 = (n//2)*d
        value.sort()
        print(math.floor(value[1]+dum1))

Submission status: Wrong Answer

Solution code:
import math
q,h,s,d = map(int,input().split())
n = int(input())
value = [0]*4
value[0] = q*4
value[1] = h*2
value[2] = s
value[3] = d/2
dum = min(value)
ind = value.index(dum)
if ind == 0:
    print(value[0]*n)
elif ind == 1:
    print(value[1]*n)
elif ind == 2:
    print(value[2]*n)
else:
    if n == 1:
        value.sort()
        print(value[1])
    elif n%2 == 0:
        print(math.floor(value[3]*n))
    else:
        dum1 = n//2*d
        value.sort()
        print(math.floor(value[1]+dum1))

Submission status: Wrong Answer

Solution code:
import math
q,h,s,d = map(int,input().split())
n = int(input())
value = [0]*4
value[0] = q*4
value[1] = h*2
value[2] = s
value[3] = d/2
dum = min(value)
ind = value.index(dum)
if ind == 0:
    print(value[0]*n)
elif ind == 1:
    print(value[1]*n)
elif ind == 2:
    print(value[2]*n)
else:
    if n == 1:
        value.sort()
        print(value[1])
    elif n%2 == 0:
        print(math.floor(value[3]*n))
    else:
        dum1 = n//2*2*value[3]
        value.sort()
        print(math.floor(value[1]+dum1))

Submission status: Wrong Answer

Solution code:
import math
q,h,s,d = map(int,input().split())
n = int(input())
value = [0]*4
value[0] = q*4
value[1] = h*2
value[2] = s
value[3] = d/2
dum = min(value)
ind = value.index(dum)
if ind == 0:
    print(value[0]*n)
elif ind == 1:
    print(value[1]*n)
elif ind == 2:
    print(value[2]*n)
else:
    if n == 1:
        value.sort()
        print(value[1])
    elif n%2 == 0:
        print(math.floor(value[3]*n))
    else:
        dum1 = n//2*value[3]*2
        value.sort()
        print(math.floor(value[1]+dum1))

Submission status: Wrong Answer

Solution code:
Q,H,S,D = map(int,input().split())
ans = 0
N = int(input())
costs = sorted([(Q*8,0.25),(H*4,0.5),(S*2,1.0),(D,2.0)])
for cost,v in costs:
    if N < v:
        continue
    if v == 0.25:
        cost //= 8
    elif v == 0.5:
        cost //= 4
    elif v == 1.0:
        cost //= 2
    else:
        cost //= 1
    a = N // v
    if (a*v) % v != 0:
        a -= 1
    N -= v * a
    ans += cost * a
    if N == 0:
        break
print(int(ans))

Submission status: Wrong Answer

Solution code:
Q,H,S,D = map(int,input().split())
ans = 0
N = int(input())
costs = sorted([(Q*8,0.25),(H*4,0.5),(S*2,1.0),(D,2.0)])
for cost,v in costs:
    if N < v:
        continue
    if v == 0.25:
        cost /= 8
    elif v == 0.5:
        cost /= 4
    elif v == 1.0:
        cost /= 2
    a = N // v
    N -= v * a
    ans += cost * a
    if N == 0:
        break
print(int(ans))

Submission status: Wrong Answer

Solution code:
# For taking integer inputs.
import math


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


Q, H, S, D = invr()
N = inp()

Q1 = Q / 0.25
H1 = H / 0.5
S1 = S / 1
D1 = D / 2

m = min(Q1, H1, S1, D1)
res = 0
if m == D1 and N > 1:
    t1 = (N - (N % 2)) * D1
    t2 = (N % 2) * min(Q1, H1, S1)
    res = t1 + t2
elif N == 1:
    res = N * min(Q1, H1, S1)
else:
    res = N * m
print(int(res))

Submission status: Wrong Answer

Solution code:
# For taking integer inputs.
import math


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


Q, H, S, D = invr()
N = inp()

Q1 = Q / 0.25
H1 = H / 0.5
S1 = S / 1
D1 = D / 2

m = min(Q1, H1, S1, D1)
res = 0
if m == D1 and N > 1:
    t1 = (N - (N % 2)) * D1
    t2 = (N % 2) * min(Q1, H1, S1)
    res = t1 + t2
else:
    res = N * min(Q1, H1, S1)
print(int(res))

Submission status: Wrong Answer

Solution code:
# For taking integer inputs.
import math


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


Q, H, S, D = invr()
N = inp()

Q1 = Q / 0.25
H1 = H / 0.5
S1 = S / 1
D1 = D / 2

m = min(Q1, H1, S1, D1)
res = 0
if m == D1 and N > 1:
    t1 = (N - (N % 2)) * D1
    t2 = (N % 2) * min(Q1, H1, S1)
    res = t1 + t2
else:
    res = N * m
print(int(res))

Submission status: Wrong Answer

Solution code:
# For taking integer inputs.
import math


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


Q, H, S, D = invr()
N = inp()

Q1 = Q / 0.25
H1 = H / 0.5
S1 = S / 1
D1 = D / 2

m = min(Q1, H1, S1, D1)
res = 0
if m == D1:
    t1 = (N - (N % 2)) * D1
    t2 = (N % 2) * min(Q1, H1, S1)
    res = t1 + t2
else:
    res = N * m
print(int(res))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    q,h,s,d=map(int,input().split())
    N=int(input())
    
    L=[[0.25,q,8*q],[0.5,h,4*h],[1,s,2*s],[2,d,d]]
    L=sorted(L, key=lambda x: x[2])

    ans=0
    i=0
    while True:

        ans+=(N//L[i][0])*L[i][1]
        N-=(N//L[i][0])*L[i][0]

        if N==0: break
        else: i+=1
    print(int(ans))

    
resolve()

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
b=[Q,H,S,D]
a=sorted(b)
if a[0]==D and n%2==1:
    ans=(n//2)*d+a[1]
else:
    ans=n*a[0]
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if n % 2 == 0:
    m += (n / 2) * l[3]
else:
    m += (n // 2) * l[3] + l[2]

print(int(m))

Submission status: Wrong Answer

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())
m = 0
l = {0.25: q, 0.5: h, 1: s, 2: d}
p = {2: d/8, 1: s/4, 0.5: h/2, 0.25: q}
minL = min(p, key=p.get)

while True:
    if minL <= n:
        if n % minL == 0:
            m += n / minL * l[minL]
            break
        else:
            m += (n // minL) * l[minL]
            n -= (minL * (n // minL))
            del p[minL]
            minL = min(p, key=p.get)
    else:
        del p[minL]
        minL = min(p, key=p.get)

print(int(m))

Submission status: Wrong Answer

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())
m = 0
l = {0.25: q, 0.5: h, 1: s, 2: d}
p = {0.25: q, 0.5: h/2, 1: s/4, 2: d/8}
minL = min(p, key=p.get)

while True:
    if minL <= n:
        if n % minL == 0:
            m += n / minL * l[minL]
            break
        else:
            m += (n // minL) * l[minL]
            n -= (minL * (n // minL))
            del p[minL]
            minL = min(p, key=p.get)
    else:
        del p[minL]
        minL = min(p, key=p.get)

print(int(m))

Submission status: Wrong Answer

Solution code:
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
Q,H,S,D = LI()
N = I()
min_1 = min(Q*4,H*2,S)
price = [min_1,D]
if 2*min_1<=D:
    ans = min_1*N
else:
    ans = N//2*D+min_1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
QHSD = LI()
N = I()
ans = 0
list_QHSD = [0.25,0.5,1,2]
QHSD2 = [QHSD[0]*8,QHSD[1]*4,QHSD[2]*2,QHSD[3]]
for _ in range(4):
    ans += (N//list_QHSD[QHSD2.index(min(QHSD2))])*QHSD[QHSD2.index(min(QHSD2))]
    N -= (N//list_QHSD[QHSD2.index(min(QHSD2))])*list_QHSD[QHSD2.index(min(QHSD2))]
    QHSD2[QHSD2.index(min(QHSD2))] = float('INF')
print(int(ans))

Submission status: Wrong Answer

Solution code:
p = list(map(int, input().split()))
n = int(input())
eff = [p[0], p[1] / 2, p[2] / 4, p[3] / 8]
g = [0.25, 0.5, 1, 2]
total = 0
ans = 0
def calc(i):
    global total, ans
    k = eff.index(min(eff[: i + 1]))
    ans += (n - total) // g[k] * p[k]
    total += (n - total) // g[k] * g[k]


while total != n:
    #print(total)
    if n - total >= 2:
        calc(3)
    elif n - total >= 1:
        calc(2)
    elif n - total >= 0.5:
        calc(1)
    else:
        total += 0.25
        ans += p[0]
print(int(ans))

Submission status: Wrong Answer

Solution code:
p = list(map(int, input().split()))
n = int(input())
eff = [p[0], p[1] / 2, p[2] / 4, p[3] / 8]
g = [0.25, 0.5, 1, 2]
total = 0
ans = 0
def calc(i):
    global total, ans
    k = eff.index(min(eff[: i + 1]))
    ans += (n - total) // g[k] * p[k]
    total += (n - total) // g[k] * g[k]


while total != n:
    #print(total)
    if n - total >= 2:
        calc(3)
    elif n - total >= 1:
        calc(2)
    elif n - total >= 0.5:
        calc(1)
    else:
        total += 0.25
        ans = p[0]
print(int(ans))

Submission status: Wrong Answer

Solution code:
Q,H,S,D = list(map(int,input().split()))
N = int(input())
TL = sorted([(0.25,Q,8*Q),(0.5,H,4*H),(1,S,2*S),(2,D,D)],key=lambda x: x[2])
ans = 0
if N >= TL[0][0]:
    ans += (N//TL[0][0])*TL[0][1]
    N %= TL[0][0]
if N >= TL[1][0]:
    ans += (N//TL[1][0])*TL[1][1]
    N %= TL[1][0]
if N >= TL[2][0]:
    ans += (N//TL[2][0])*TL[2][1]
    N %= TL[2][0]
if N >= TL[3][0]:
    ans += (N//TL[3][0])*TL[3][1]
    N %= TL[3][0]
print(int(ans))

Submission status: Wrong Answer

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

# 1リットルあたりの単価を出す
s = min([Q*4, H*2, S])
d = D/2

# Nが2で割れる時はリッターあたりの最安値*N
if N%2==0:
    print(int(N*min(s, d)))
# Nが2で割れない時は、N-1までは最安値で買って、残り1リットルはsの単価で買う
else:
    print(int((N-1)*min(s, d) + s))

Submission status: Wrong Answer

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

s = min([Q*4, H*2, S])
d = D/2

if N%2==0:
    print(int(N*min(s, d)))
else:
    print(int((N-1)*min(s, d) + s))

Submission status: Wrong Answer

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

s = min([Q*4, H*2, S])
d = D//2

if N%2==0:
    print(N*min(s, d))
else:
    print((N-1)*min(s, d) + s)

Submission status: Wrong Answer

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

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

r = min([q, h, s, d])

if r != d:
    print(r*N)
else:
    if N%2==0:
        print(r*N)
    else:
        ans = (N-1)*r
        ans += min([q, h, s])
        print(ans)

Submission status: Wrong Answer

Solution code:
# A - Ice Tea Store

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

for_1L = min(4*Q, 2*T, S)
for_2L = min(for_1L, D)

print((N//2)*for_2L + (N%2)*for_1L)