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

choice = []
choice.append([Q*8 , 1])
choice.append([H*4 , 2])
choice.append([S*2 , 4])
choice.append([D , 8])

choice.sort()
for c in choice:
    if c[1] == 1:
        c[0] /= 8
    elif c[1] == 2:
        c[0] /= 4
    elif c[1] == 4:
        c[0] /= 2

ans = 0
N = N * 4

while N != 0:
    if int(N / choice[0][1]) != 0:
        kosu = int(N / choice[0][1])
        N -= kosu * choice[0][1]
        ans += kosu * choice[0][0]

    elif int(N / choice[1][1]) != 0:
        kosu = int(N / choice[1][1])
        N -= kosu * choice[1][1]
        ans += kosu * choice[1][0]

    elif int(N / choice[2][1]) != 0:
        kosu = int(N / choice[2][1])
        N -= kosu * choice[2][1]
        ans += kosu * choice[2][0]

    elif int(N / choice[3][1]) != 0:
        kosu = int(N / choice[3][1])
        N -= kosu * choice[3][1]
        ans += kosu * choice[3][0]

print(int(ans))

Submission status: Wrong Answer

Solution code:
A = input()
cand = set([A])
l = len(A)
for i in range(0, l - 1):
    for j in range(i + 1,l):
        p = A[i:j+1]
        cand.add((A[0:i] + p[::-1] + A[j + 1:l]))
print(len(cand))

Submission status: Wrong Answer

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

d_buy = n // 2
s_buy = (n - d_buy * 2) // 1
h_buy = (n - (d_buy * 2 + s_buy * 1)) // 0.5
q_buy = (n - (d_buy * 2 + s_buy * 1 + h_buy * 0.5)) // 0.25

cp = [q*8, h*4, s*2, d]
if min(cp) == cp[0]:
    q_buy += d_buy * 8
    d_buy = 0
elif min(cp) == cp[1]:
    h_buy += d_buy * 4
    d_buy = 0
elif min(cp) == cp[2]:
    s_buy += d_buy * 2
    d_buy = 0

cp = [q*8, h*4, s*2]
if min(cp) == cp[0]:
    q_buy += s_buy * 4
    s_buy = 0
elif min(cp) == cp[1]:
    h_buy += s_buy * 2
    s_buy = 0

cp = [q*8, h*4]
if min(cp) == cp[0]:
    q_buy += h_buy * 2
    h_buy = 0



sum = d * d_buy + s * s_buy + h * h_buy + q * q_buy
print(int(sum))

Submission status: Wrong Answer

Solution code:
def buy(q, h, s, d, n):
    min = float("inf")
    c_liter = 0
    c_price = 0
    while c_price > n:
        c_liter += 2
        c_price += d
        if c_liter == n and c_price < min:
            min = c_price
        while c_price > n:
            c_liter += 1
            c_price += s
            if c_liter == n and c_price < min:
                min = c_price
            while c_price > n:
                c_liter += 0.5
                c_price += h
                if c_liter == n and c_price < min:
                    min = c_price
                while c_price > n:
                    c_liter += 0.25
                    c_price += q
                    if c_liter == n and c_price < min:
                        min = c_price
    return min


if __name__ == '__main__':
    price = input()
    prices = price.split()
    prices = list(map(int, prices))
    n = int(input())
    print(buy(prices[0], prices[1], prices[2], prices[3], n))

Submission status: Wrong Answer

Solution code:
def buy(q, h, s, d, n):
    min = float("inf")
    c_liter = 0
    c_price = 0
    while c_price > n:
        c_liter += 2
        c_price += d
        if c_price == n and c_price < min:
            min = c_price
        while c_price > n:
            c_liter += 1
            c_price += s
            if c_price == n and c_price < min:
                min = c_price
            while c_price > n:
                c_liter += 0.5
                c_price += h
                if c_price == n and c_price < min:
                    min = c_price
                while c_price > n:
                    c_liter += 0.25
                    c_price += q
                    if c_price == n and c_price < min:
                        min = c_price
    return min


if __name__ == '__main__':
    price = input()
    prices = price.split()
    prices = list(map(int, prices))
    n = int(input())
    print(buy(prices[0], prices[1], prices[2], prices[3], n))

Submission status: Wrong Answer

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

choice = []
choice.append([Q*8 , 1])
choice.append([H*4 , 2])
choice.append([S*2 , 4])
choice.append([D , 8])

choice.sort()
for c in choice:
    if 1 in c:
        c[0] /= 8
    elif 2 in c:
        c[0] /= 4
    elif 4 in c:
        c[0] /= 2

cnt = 0
ans = 0
N = N * 4

while N != 0:
    if int(N / choice[0][1]) != 0:
        kosu = int(N / choice[0][1])
        N -= kosu * choice[0][1]
        ans += kosu * choice[0][0]

    elif int(N / choice[1][1]) != 0:
        kosu = int(N / choice[1][1])
        N -= kosu * choice[1][1]
        ans += kosu * choice[1][0]

    elif int(N / choice[2][1]) != 0:
        kosu = int(N / choice[2][1])
        N -= kosu * choice[2][1]
        ans += kosu * choice[2][0]

    elif int(N / choice[3][1]) != 0:
        kosu = int(N / choice[3][1])
        N -= kosu * choice[3][1]
        ans += kosu * choice[3][0]

print(int(ans))

Submission status: Wrong Answer

Solution code:
def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

q, h, s, d = read_line(int, int, int, int)
n, = read_line(int)

# print(q, h, s, d)
# print(n)

# print()

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

# print(list(menu))

charge = 0
while True:
    for size, (price, _) in menu:
        if n >= size:
            count = n // size
            charge += count * price
            n -= size * count
        if n == 0:
            print(int(charge))
            exit()

Submission status: Wrong Answer

Solution code:
Q, H, S, D = input().split()
Q, H, S, D = int(Q), int(H), int(S), int(D) # price 0.25 0.5 1.0 2.0
N = int(input())

per_2l_price = [Q*8, H*4, S*2, D]
per_1l_price = [Q*4, H*2, S]
per_05_price = [Q*2, H]
per_025_price = [Q]
needtobuy_l = N
needtobuy_m = 0


def st_min(lt):
    min_num = 0
    min_ = 10000000001
    for i in range(len(lt)):
        if lt[i] < min_:
            min_num = i
            min_ = lt[i]
    return min_num
st_min

if needtobuy_l >= 2.0:
    mn = st_min(per_2l_price)
    needtobuy_m += per_2l_price[mn] * (needtobuy_l // 2.0)
    needtobuy_l -= 2.0 * (needtobuy_l // 2.0)
if needtobuy_l >= 1.0:
    mn = st_min(per_1l_price)
    needtobuy_m += per_1l_price[mn] * (needtobuy_l // 1.0)
    needtobuy_l -= 1.0 * (needtobuy_l // 1.0)
if needtobuy_l >= 0.5:
    mn = st_min(per_05_price)
    needtobuy_m += per_05_price[mn] * (needtobuy_l // 0.5)
    needtobuy_l -= 0.5 * (needtobuy_l // 0.5)
if needtobuy_l >= 0.25:
    needtobuy_m += Q * (needtobuy_l // 0.25)
    needtobuy_l -= 0.25 * (needtobuy_l // 0.25)

print(int(needtobuy_m))

Submission status: Wrong Answer

Solution code:
import math
tmp=map(int, raw_input().split(" "))
num=int(raw_input())
en=0
arr=[]
k=1
for i in tmp:
    arr.append(float(i)/k)
    k=k*2

#print arr.index(min(arr))

n=num
while True:
    if n >= 2:
        target=arr.index(min(arr))
    elif n >= 1:
        target=arr[0:3].index(min(arr[0:3]))
    elif n >= 0.5:
        target=arr[0:2].index(min(arr[0:2]))
    elif n >= 0.25:
        target=arr[0:1].index(min(arr[0:1]))

    #print "target",target
    if target==3:
        en+=math.floor(n/2)*tmp[target]
        n=float(n)%2
    elif target==2:
        en+=math.floor(n/1)*tmp[target]
        n=float(n)%1
    elif target==1:
        en+=math.floor(n/0.5)*tmp[target]
        n=float(n)%0.5
    elif target==0:
        en+=math.floor(n/0.25)*tmp[target]
        n=float(n)%0.25
    #print n
    #print en,"en"
    if n==0:
        break
print int(en)

Submission status: Wrong Answer

Solution code:
import math

l = list(map(int, input().split()))
N = int(input())


l.reverse()

eff = []
price = 0

for i in range(len(l)):
	eff.append(l[i]/2/(2**(-i)))

for i in range(len(l)):

	maxVol = 2/(2**i)
	nb = math.floor(N/maxVol)
	N -= nb * maxVol 
	max_idx = eff.index(min(eff))
	price += eff[max_idx]*nb*maxVol

	l = l[1:]
	eff = eff[1:]

print(int(price))

Submission status: Wrong Answer

Solution code:
import math
tmp=map(int, raw_input().split(" "))
num=int(raw_input())
en=0
arr=[]
k=1
for i in tmp:
    arr.append(i/k)
    k=k*2

#print arr.index(min(arr))

n=num
while True:
    if n >= 2:
        target=arr.index(min(arr))
    elif n >= 1:
        target=arr[0:3].index(min(arr[0:3]))
    elif n >= 0.5:
        target=arr[0:2].index(min(arr[0:2]))
    elif n >= 0.25:
        target=arr[0:1].index(min(arr[0:1]))

    #print "target",target
    if target==3:
        en+=math.floor(n/2)*tmp[target]
        n=float(n)%2
    elif target==2:
        en+=math.floor(n/1)*tmp[target]
        n=float(n)%1
    elif target==1:
        en+=math.floor(n/0.5)*tmp[target]
        n=float(n)%0.5
    elif target==0:
        en+=math.floor(n/0.25)*tmp[target]
        n=float(n)%0.25
    #print n
    #print en,"en"
    if n==0:
        break
print int(en)

Submission status: Wrong Answer

Solution code:
a,b,c,d=[int(i) for i in input().split()]
M=[4*a,2*b,c,d/2]
N=int(input())

if M[0]==min(M):
    print(N*M[0])
elif M[1]==min(M):
    print(N*M[1])
elif M[2]==min(M):
    print(N*M[2])
else:
    if N%2==0:
        print(int(N*M[3]))
    else:
        if M[0]==min(M):
            print(N//2*int(M[3]*2)+M[0])
        elif M[1]==min(M):
            print(N//2*int(M[3]*2)+M[1])
        elif M[2]==min(M):
            print(N//2*int(M[3]*2)+M[2])

Submission status: Wrong Answer

Solution code:
Q, H, S, D = input().split()
Q, H, S, D = int(Q), int(H), int(S), int(D) # price 0.25 0.5 1.0 2.0 
N = int(input())


def st_min(lt):
    min_num = 0
    min_ = 10000000001
    for i in range(len(lt)):
        if lt[i] < min_:
            min_num = i
            min_ = lt[i]
    return min_num
st_min


per_2l_price = [Q*8, H*4, S*2, D]
per_1l_price = [Q*4, H*2, S]
per_05_price = [Q*2, H]

needtobuy_l = N
needtobuy_m = 0
if N >= 2.0:
    mn = st_min(per_2l_price)
    needtobuy_m += per_2l_price[mn] * (needtobuy_l // 2.0)
    needtobuy_l -= 2.0 * (needtobuy_l // 2.0)
if N >= 1.0:
    mn = st_min(per_1l_price)
    needtobuy_m += per_1l_price[mn] * (needtobuy_l // 1.0)
    needtobuy_l -= 1.0 * (needtobuy_l // 1.0)
if N >= 0.5:
    mn = st_min(per_05_price)
    needtobuy_m += per_05_price[mn] * (needtobuy_l // 0.5)
    needtobuy_l -= 0.5 * (needtobuy_l // 0.5)
if N >= 0.25:
    needtobuy_m += Q * (needtobuy_l // 0.25)
    needtobuy_l -= 0.25 * (needtobuy_l // 0.25)

print(int(needtobuy_m))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
def inpl(): return tuple(map(int, input().split()))

volume = [0.25, 0.5, 1, 2]
value = {k:v for k, v in zip(volume, inpl())}
cosp = {k:v/k for k, v in value.items()}
N = int(input())
res = 0

for k, _ in sorted(cosp.items(), key=lambda x: x[1]):
    res += (N // k)*value[k]
    N = N % k
print(int(res))

Submission status: Wrong Answer

Solution code:
Price = [int(i) for i in input().split()]
N = int(input())

A = [[4, 2, 1, 0.5][i]*Price[i] for i in range(4)]
a = min(A[:3]) # minimum price per 1L (2.0L<)
b = A[3] #price per 1L (2.0L)

if b >= a:
    print(int(a*N))
else:
    print(int(2*b*(N//2) + a*(N%2)))

Submission status: Wrong Answer

Solution code:
import math
tmp=map(int, raw_input().split(" "))
num=int(raw_input())
en=0
arr=[]
k=1
for i in tmp:
    arr.append(i/k)
    k=k*2

#print arr.index(min(arr))

n=num
while True:
    if n >= 2:
        target=arr.index(min(arr))
    elif n >= 1:
        target=arr[0:3].index(min(arr[0:3]))
    elif n >= 0.5:
        target=arr[0:2].index(min(arr[0:2]))
    elif n >= 0.25:
        target=arr[0:1].index(min(arr[0:1]))

    #print "target",target
    if target==3:
        en+=math.floor(n/2)*tmp[target]
        n=float(n)%2
    elif target==2:
        en+=math.floor(n/1)*tmp[target]
        n=float(n)%1
    elif target==1:
        en+=math.floor(n/0.5)*tmp[target]
        n=float(n)%0.5
    elif target==0:
        en+=math.floor(n/0.25)*tmp[target]
        n=float(n)%0.25
    #print n
    #print en,"en"
    if n==0:
        break
print en

Submission status: Wrong Answer

Solution code:
q,h,s,d=map(int,raw_input().split())
n=input()
q1=q/0.25
h1=h/0.5
s1=s
d1=d/2.0
l=[[q1,0.25],[h1,0.5],[s1,1.0],[d1,2.0]]
l.sort()
ans=0
for i in range(4):
    if l[i][1]>n:
        continue
    else:
        k=int(n/l[i][1])
        ans+=l[i][0]*k*l[i][1]
        n-=k*l[i][1]
        if n<=0:
            break
print int(ans)

Submission status: Wrong Answer

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

import numpy as np

n = N
s = [8,4,2,1]
p = [D,S,H,Q]
pp = np.array([s[3-i]/p[3-i] for i in range(4)]).argsort()
c = 0

if 0 in s:
    print(c)
else:
    for i in pp:
        nn = n//s[i]
        n -= s[i] * nn
        c += p[i] * nn
    print(c)

Submission status: Wrong Answer

Solution code:
Price = [int(i) for i in input().split()]
N = int(input())

A = [[4, 2, 1, 0.5][i]*Price[i] for i in range(4)]
a = min(A[:3])
b = A[3]

if b > a:
    print(int(a*N))
else:
    print(int(2*b*(N//2) + a*(N%2)))

Submission status: Wrong Answer

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

import numpy as np

n = N
#print(n)
s = [8,4,2,1]
p = [D,S,H,Q]
#print(p)
pp = np.array([s[3-i]/p[3-i] for i in range(4)]).argsort()
#print(pp)
c = 0

for i in pp:
    nn = n//s[i]
    n -= s[i] * nn
    c += p[i] * nn
print(c)

Submission status: Wrong Answer

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

x = min(4 * q, 2 * d, s)

if n % 2 == 0:
    print(min(x, d // 2) * n)
elif 2 * x < d:
    print(x * n)
else:
    print(d * (n // 2) + x)

Submission status: Wrong Answer

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

A = [Q, H, S, D]
B = [0.25, 0.5, 1, 2]
M = [Q*4, H*2, S, D/2]

result = 0
for i in range(4):
    m = min(M)
    j = M.index(m)
    M.remove(m)
    n = N%B[j]
    result += N//B[j]*A[j]
    if n == 0:
        break
    N = n

print(int(result))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def main():
    prices = get_ln_int_inputs()
    N = get_ln_int_inputs()[0]
    M = N * 4

    result = [0, 0, 0, 0]

    prices_per_litre = [0, 0, 0, 0]
    for i in range(4):
        prices_per_litre[i] = prices[i] / (1 << i)
    
    price_rank = [sorted(prices_per_litre).index(price_per_l) for price_per_l in prices_per_litre]

    idx = 0
    if price_rank[idx] == 3:
        result[3] += M // 8
        M %= 8
        idx += 1
    
    cp = price_rank[idx]
    result[cp] += M // (1 << cp)

    print(sum(prices[i] * result[i] for i in range(4)))
    return


main()

Submission status: Wrong Answer

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

up = sorted([(q, 1), (h/2, 2), (s/4, 4), (d/8, 8)])

nq = n * 4
price = 0
for i, e in enumerate(up):
    if nq >= e[1]:
        nn, nq = divmod(nq, e[1])
        price += (e[0] * e[1]) * nn
print(int(price))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def main():
    prices = get_ln_int_inputs()
    N = get_ln_int_inputs()[0]
    M = N * 4

    result = [0, 0, 0, 0]

    prices_per_litre = [0, 0, 0, 0]
    for i in range(4):
        prices_per_litre[i] = prices[i] >> i
    
    price_rank = [sorted(prices_per_litre).index(price_per_l) for price_per_l in prices_per_litre]

    idx = 0
    if price_rank[idx] == 3:
        result[3] += M // 8
        M %= 8
        idx += 1
    
    cp = price_rank[idx]
    result[cp] += M // (1 << cp)

    print(sum(prices[i] * result[i] for i in range(4)))
    return


main()

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':

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

    #各サイズの量
    amounts = {'Q' : 0.25, 'H' : 0.5, 'D' : 1.0, 'D' : 2.0}
    #1リットルあたりの値段
    sizes = {'Q' : int(Q * 4.0), 'H' : int(H * 2.0), 'S' : S, 'D' : int(D * 0.5)}
    sizes = sorted(sizes.items(), key=lambda x: x[1])
    print(sizes)
    sum_price = 0

    while N > 0:
        for size in sizes:

            if size[0] != 'D':
                if N - 1 >= 0:
                    N -= 1
                    sum_price += size[1]
                else:
                    break
            else:
                if N - 2 >= 0:
                    N -= 2
                    sum_price += D
                else: break



    print(sum_price)

Submission status: Wrong Answer

Solution code:
a=map(int,raw_input().split())
n=int(raw_input())
b=[4,2,1,0.5]
c = zip(a,b)
c = sorted(c,key=lambda x : x[0]*x[1])
res = 0
if c[0][1] < 0.7 :
    res = (n/2)*c[0][0] + ((n%2)*c[1][1])*c[1][0]
else :
    res = (n*c[0][1])*c[0][0]
print '%.0f'%res

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

money = 0

if n % 2 == 0:
    tmp = n / 2
    if s * 2 > d:
        money = tmp * d
    elif h * 4 > s * 2:
        money = tmp * (s * 2)
    elif q * 8 > h * 4:
        money = tmp * (h * 4)
    else:
        money = tmp * (q * 8)
else:
    tmp = n // 2
    if s * 2 > d:
        money = tmp * d
    elif h * 4 > s * 2:
        money = tmp * (s * 2)
    elif q * 8 > h * 4:
        money = tmp * (h * 4)
    else:
        money = tmp * (q * 8)
    
    if h * 2 > s:
        money += s
    elif q * 4 > h * 2:
        money += h * 2
    else:
        money += q * 4

print(money)

Submission status: Wrong Answer

Solution code:
#!usr/bim/python
#! -*- coding: utf-8 -*-


import numpy as np

qhsd = raw_input()
qhsd = qhsd.split()
qhsd = map(int,qhsd)

n = raw_input()
n = int(n)

a = np.zeros(4,dtype = np.int64)
a[0] = qhsd[0]*8
a[1] = qhsd[1]*4
a[2] = qhsd[2]*2
a[3] = qhsd[3]

b = np.zeros(4,dtype = np.int64)
for i in range(4):
    b[i] = np.argmin(a)
    a[np.argmin(a)] = max(a)+1

l = [0.25,0.5,1,2]

ans = 0

for i in b:
    x = n / l[i]
    n -= x * l[i]
    ans += qhsd[i] * x
    #print i, x, n, ans

print int(ans)

Submission status: Wrong Answer

Solution code:
import math

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

N = int(input())
ans = 0
Q *= 4
H *= 2
twiceQ = Q * 2
twiceH = H * 2
twiceS = S * 2

a = N % 2
if a == 0:
    num = N / 2
    ans += num * min(twiceQ, twiceH, twiceS, D)
else:
    num = (N-1) / 2
    ans += num * min(twiceQ, twiceH, twiceS, D)
    ans += min(Q, H, S)
print(math.floor(ans))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def main():
    prices = get_ln_int_inputs()
    N = get_ln_int_inputs()[0]

    M = N * 4

    result = [0, 0, 0, 0]

    prices_per_litre = [0, 0, 0, 0]
    for i in range(4):
        prices_per_litre[i] = prices[i] >> i
    
    price_rank = [sorted(prices_per_litre).index(price_per_l) for price_per_l in prices_per_litre]

    for i in range(4):
        cheapest = price_rank[i]
        cheapest_price = 1 << cheapest
        result[cheapest] += M // cheapest_price
        M %= cheapest_price

    print(sum(prices[i] * result[i] for i in range(4)))

    return


main()

Submission status: Wrong Answer

Solution code:
a=map(int,raw_input().split())
n=int(raw_input())
b=[0.25,0.5,1,2]
c = zip(a,b)
c = sorted(c,key=lambda x : x[0]/x[1])
res = 0
if c[0][1] == 2 :
    res = (n/2)*c[0][0] + ((n%2)/c[1][1])*c[1][0]
else :
    res = (n/c[0][1])*c[0][0]
print '%.0f'%res

Submission status: Wrong Answer

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

N = int(input())
ans = 0
Q *= 4
H *= 2
twiceQ = Q * 2
twiceH = H * 2
twiceS = S * 2

a = N % 2
if a == 0:
    num = N / 2
    ans += num * min(twiceQ, twiceH, twiceS, D)
else:
    num = (N-1) / 2
    ans += num * min(twiceQ, twiceH, twiceS, D)
    ans += min(Q, H, S)
print(round(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

N = int(input())
ans = 0
Q *= 4
H *= 2
twiceQ = Q * 2
twiceH = H * 2
twiceS = S * 2

a = N % 2
if a == 0:
    num = N / 2
    ans += num * min(twiceQ, twiceH, twiceS, D)
else:
    num = (N-1) / 2
    ans += num * min(twiceQ, twiceH, twiceS, D)
    ans += min(Q, H, S)
print(ans)

Submission status: Wrong Answer

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

cost = 0
div2 = n // 2

a = min(q * 8, h * 4, s * 2, d)

n -= div2 * 2
cost += div2 * a

div1 = n
a = min(q * 4, h * 2, s)

n -= div1
cost += div1 * a

divh = n // 0.5
a = min(q * 2, h)

n -= divh
cost += divh * a

if n == 0.25:
    cost += q

print(int(cost))

Submission status: Wrong Answer

Solution code:
q, h, s, d = [int(i) for i in input().split()]
n = int(input())
q /= 0.25
h /= 0.5
d /= 2

x2 = min([q,h,s,d]) * 2
x1 = min([q,h,s])
x05 = min([q,h])
x025 = q
ret = 0

ret += (n // 2) * x2
n %= 2
ret += (n) * x1
print(int(ret))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
def II(): return int(input())
def ILI(): return list(map(int, input().split()))


def read():
    Q, H, S, D = ILI()
    N = II()
    return (Q, H, S, D, N)


def solve(Q, H, S, D, N):
    l_all = []
    l_all.append((Q * 4, "q"))
    l_all.append((H * 2, "h"))
    l_all.append((S, "s"))
    l_all.append((D / 2, "d"))
    l_all.sort(key= lambda x: x[0])
    ans = 0
    rest = N
    for i, j in l_all:
        if j == "q":
            div, mod = divmod(rest, 0.25)
            ans += div * Q
            rest = mod
        if j == "h":
            div, mod = divmod(rest, 0.5)
            ans += div * H
            rest = mod
        if j == "s":
            div, mod = divmod(rest, 1)
            ans += div * S
            rest = mod
        else:
            div, mod = divmod(rest, 2)
            ans += div * D
            rest = mod

    return int(ans)


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
def II(): return int(input())
def ILI(): return list(map(int, input().split()))


def read():
    Q, H, S, D = ILI()
    N = II()
    return (Q, H, S, D, N)


def solve(Q, H, S, D, N):
    l_all = []
    l_all.append((Q * 4, "q"))
    l_all.append((H * 2, "h"))
    l_all.append((S, "s"))
    l_all.append((D / 2, "d"))
    l_all.sort(key= lambda x: x[0])
    ans = 0
    rest = N
    for i, j in l_all:
        if j == "q":
            div, mod = divmod(rest, 0.25)
            ans += div * Q
            rest = mod
        if j == "h":
            div, mod = divmod(rest, 0.5)
            ans += div * H
            rest = mod
        if j == "s":
            div, mod = divmod(rest, 1)
            ans += div * S
            rest = mod
        else:
            div, mod = divmod(rest, 2)
            ans += div * D
            rest = mod

    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from fractions import Fraction

a, b, c, d = map(int, raw_input().split())
N = input()

A = a / Fraction(1, 4)
B = b / Fraction(1, 2)
C = c / Fraction(1, 1)
D = d / Fraction(2, 1)
ans = 0

if D < A and D < B and D < C:
    ans += N / 2 * d
    N %= 2
    ans += min(A, B, C)
else:
    ans += min(A, B, C) * N

print int(ans)

Submission status: Wrong Answer

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

Submission status: Time Limit Exceeded

Solution code:
q,h,s,d = [int(i) for i in input().split()]

n = int(input())

total = 0
temp = n

hmin = min(2*q,h)
smin = min(2*hmin,s)
dmin = min(2*smin,d)

while(temp>=2):
	total += dmin
	temp -= 2

while(temp>=1):
	total += smin
	temp -= 1

while(temp>=0.5):
	total += hmin
	temp -= 0.5

while(temp>0):
	total += q
	temp -= 0.25

print(total)

Submission status: Time Limit Exceeded

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

p025 = Q
p05 = min(H, p025 * 2)
p1 = min(S, p05 * 2)
p2 = min(D, p1 * 2)

ans = 0
while N > 0:
    if N >= 2:
        N -= 2
        ans += p2
    elif N >= 1:
        N -= 1
        ans += p1

print(ans)

Submission status: Time Limit Exceeded

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

ans = 10**9
for w in range(N//2+1):
    for z in range(N-2*w+1):
        for y in range(2*(N-2*w-z)+1):
            x = 4 * (N - 2*w - z - y//2)
            ans = min(ans, Q*x + H*y + S*z + D*w)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
Q,H,S,D = map(int,input().split())
N = int(input())
N *= 100
H = min(H,2*Q)
S = min(S,2*H)
D = min(D,2*S)
ans = 0
while N > 0:
  if N >= 200:
    ans += D
    N -= 200
  elif N >= 100:
    ans += S
    N -= 100
  elif N >= 50:
    ans += H
    N -= 50
  elif N >= 25:
    ans += Q
    N -= 25
print(ans)

Submission status: Time Limit Exceeded

Solution code:
m = input().split()
Q = int(m[0])
H = int(m[1])
S = int(m[2])
D = int(m[3])

ans = 0
N = int(input())

for d in range((N // 2) + 1 ):
  s_set = N - (2*d)
  for s in range(s_set + 1):
    h_set = N - (2*d + 1*s)
    for h in range(h_set * 2 +1):
      q = int( 4 * (N - (2*d + 1 * s + 0.5 * h)))
      money = d*D + s*S + h*H + q*Q

      if (ans == 0) or (ans > money):
        ans = money

print(ans)

Submission status: Time Limit Exceeded

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

for i in range(n//2+1):
    tmp = d*i+one*(n-2*i)
    ans = min(ans, tmp)
print(ans)

Submission status: Time Limit Exceeded

Solution code:

def main():
    q, h, s, d = map(int, input().split())
    n = int(input()) * 100
    h = min(h, 2*q)
    s = min(s, 2*h)
    d = min(d, 2*s)
    ans = 0
    vals = [(200, d), (100, s), (50, h), (25, q)]
    while n > 0:
        for m, val in vals:
            if m <= n:
                n -= m
                ans += val
                break
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

ans = 10 ** 9

i_max = int(n / 0.25)
for i in range(i_max+1):
	j_max = int((n - 0.25 * i)/0.5)
	for j in range(j_max+1):
		k_max = int((n - 0.25 * i - 0.5 * j))
		for k in range(k_max+1):
			l_max = int((n - 0.25 * i - 0.5 * j - k))
			for l in range(l_max+1):
				_n = 0.25 * i + 0.5 * j + k + 2 * l
				if _n != n:
					continue
				_sum = i * q + j * h + k * s + d * l
				ans = min(ans, _sum)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
val = list(map(int, input().split()))
N = int(input())
price = [v / (2 ** i)  for i, v in enumerate(val)]
sortedIndex = []
sortedPrice = sorted(price)
price2 = price.copy()
for p in sortedPrice:
    sortedIndex.append(price2.index(p))
    price2[price2.index(p)] = -1

temp = 0
ans = 0
for i in sortedIndex:
    while N > temp:
        if(N < temp + 0.25 * (2 ** i)):
            break
        temp += 0.25 * (2 ** i)
        ans += val[i]
    
print (ans)

Submission status: Time Limit Exceeded

Solution code:

if __name__ == '__main__':

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

    #各サイズの量
    amounts = {'Q' : 0.25, 'H' : 0.5, 'D' : 1.0, 'D' : 2.0}
    #1リットルあたりの値段
    sizes = {'Q' : int(Q * 4.0), 'H' : int(H * 2.0), 'S' : S, 'D' : int(D * 0.5)}
    sizes = sorted(sizes.items(), key=lambda x: x[1])
    sum_price = 0

    while N > 0:
        for size in sizes:

            if size[0] != 'D':
                if N - 1 >= 0:
                    N -= 1
                    sum_price += size[1]
                else:
                    break
            else:
                if N - 2 >= 0:
                    N -= 2
                    sum_price += D
                else: break
    print(sum_price)

Submission status: Time Limit Exceeded

Solution code:

volume = [1,2,4, 8]
value = tuple(map(int, input().split()))
N = int(input())
 
counts = [10**10 for _ in range(N*4 + 1)]
counts[0] = 0
 
for i in range(4):
    for n in range(volume[i], N*4+1):
        counts[n] = min(counts[n], counts[n-volume[i]] + value[i])
 
print(counts[-1])

Submission status: Accepted

Solution code:
# A

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

print((N//2) * min(8*Q,4*H,2*S,D) + (N % 2) * min(4*Q,2*H,S))

Submission status: Accepted

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)
    c=n//2
    if n%2==0:
        print(c*dp2)
    else:
        print(c*dp2+sp1)
    

if __name__=="__main__":
    main()

Submission status: Accepted

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%2==0:
        c=n//2
        print(c*dp2)
    # elif n%2!=0:
    else:
        c=n//2
        print(c*dp2+sp1)
    # else:
    #     print(n*sp1)
    

if __name__=="__main__":
    main()

Submission status: Accepted

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%2==0:
        c=n//2
        print(c*dp2)
    elif n%2!=0:
        c=n//2
        print(c*dp2+sp1)
    else:
        print(n*sp1)
    

if __name__=="__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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