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())
q, h, s, d = Q * 4, H * 2, S, float(D / 2)
if N == 1:
    ans = min(q, h, s)
elif N % 2 == 0:
    ans = N * min(q, h, s, d)
else:
    ans = (N - 1) * min(q, h, s, d) + min(q, h, s)
print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[29]:


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


# In[30]:


volume = [0.25, 0.5, 1, 2]
unit_c = [Q*4, H*2, S, D/2]
act_c = [Q, H, S, D]

mylist = [[volume[i], unit_c[i], act_c[i]] for i in range(len(volume))]
mylist_sorted = sorted(mylist, key=lambda x: x[1])

ans = 0
target = N
for v,c,a in mylist_sorted:
    if target == 0:
        break
    count = target//v
    ans += count*a
    target -= v*count 
#     print(v, c, a, count, target)
print(int(ans))


# In[ ]:

Submission status: Wrong Answer

Solution code:
q , h , s , d = map(int,input().split())
n = int(input())
qb = q*4
hb = h*2
db = d/2

if min(qb,hb,db,s) != db:
    print(n*min(qb,hb,s))
elif min(qb,hb,db,s) == db:
    if n % 2 == 0:
        print(n*db)
    elif n % 2 == 1:
        ans = (n//2) * d
        ans += min(qb,hb,s)
        print(ans)

Submission status: Wrong Answer

Solution code:
q , h , s , d = map(int,input().split())
n = int(input())
qb = q*4
hb = h*2
db = d//2

if min(qb,hb,db,s) != db:
    print(n*min(qb,hb,s))
elif min(qb,hb,db,s) == db:
    if n % 2 == 0:
        print(n*db)
    elif n % 2 == 1:
        ans = (n//2) * d
        ans += min(qb,hb,s)
        print(ans)

Submission status: Wrong Answer

Solution code:
q , h , s , d = map(int,input().split())
n = int(input())
qb = q*4
hb = h*2
db = d//2

if min(qb,hb,db,s) != db:
    print(n*min(qb,hb,db,s))
elif min(qb,hb,db,s) == db:
    if n % 2 == 0:
        print(n*db)
    elif n % 2 == 1:
        ans = n//2 * d
        ans += min(qb,hb,s)
        print(ans)

Submission status: Wrong Answer

Solution code:
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from collections import Counter
def resolve():
    Q,H,S,D=pin()
    N=int(input())
    Q*=4
    H*=2

    t=N%2
    ans=0
    if S*2>D:
        ans+=D*(N//2)
        #print(ans)
        N=t
    ans+=N*min(Q,H,S)
    print(ans)
#%%submit!
resolve()

Submission status: Wrong Answer

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

sorted_list = sorted([(q, 0.25), (h, 0.5), (s, 1.0), (d, 2.0)],
                     key=lambda t: t[0] / t[1])

cheapest = sorted_list[0]
if cheapest[1] == 2.0:
    # 2リットルが最安の場合
    second = sorted_list[1]
    cost = cheapest[0] * (n // 2) + second[0] * (n % 2) / second[1]
else:
    cost = cheapest[0] / cheapest[1] * n

print(int(cost))

Submission status: Wrong Answer

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

c_05 = min(2*Q, H)
c_1 = min(2*c_05, S)

if c_1 <= D:
    print(c_1 * N)
else:
    if N % 2 == 0:
        print(D * (N//2))
    else:
        print(D * (N//2) + c_1)

Submission status: Wrong Answer

Solution code:
LCOS = list(map(int, input().split()))
N = int(input())

lcos = [LCOS[0], LCOS[1]/2, LCOS[2]/4, LCOS[3]/8]
llit = [0.25, 0.5, 1.0, 2.0]

lcombi = list()
for i, j, k in zip(LCOS, lcos, llit):
    lcombi.append((i, j, k))
#print(lcombi)

lup = sorted(lcombi, key=lambda x: x[1])
#print(lup)

mny = 0
for i in range(4):
    mny += lup[i][0] * (N//lup[i][2])
    N -= lup[i][2] * (N//lup[i][2])
    if N == 0:
        break
print(int(mny))

Submission status: Wrong Answer

Solution code:
LCOS = list(map(int, input().split()))
N = int(input())

lcos = [LCOS[0], LCOS[1]/2, LCOS[2]/4, LCOS[3]/8]
llit = [0.25, 0.5, 1.0, 2.0]

lcombi = list()
for i, j, k in zip(LCOS, lcos, llit):
    lcombi.append((i, j, k))
#print(lcombi)

lup = sorted(lcombi, key=lambda x: x[1])
#print(lup)

mny = 0
for i in range(4):
    mny += lup[i][0] * (N//lup[i][2])
    N -= lup[i][2] * (N//lup[i][2])
print(int(mny))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat May  9 23:33:40 2020

@author: shinba
"""

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

n = int(input())

a = [4*q,2*h,s,d/2]

a.sort()

if a[0] != d/2:
    print(int(n*a[0]))

else:
    if n % 2 == 0:
        print(int(n*a[0]))
    else:
        print(int((n-1)*a[0])+int(a[1]))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

S = min(S,2*H,4*Q)

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

Submission status: Wrong Answer

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())
q_cp = q*8
h_cp = h*4
s_cp = s*2
d_cp = d
ans = 0
if min(q_cp,h_cp,s_cp,d_cp)==q_cp:
    ans+=n//2*q*8
elif min(q_cp,h_cp,s_cp,d_cp)==h_cp:
    ans+=n//2*h*4
elif min(q_cp,h_cp,s_cp,d_cp)==s_cp:
    ans+=n//2*s*2
else:
    ans += n//2*d
    amari = n%2
    if min(q_cp, h_cp, s_cp) == q_cp:
        ans += amari*q*4
    elif min(q_cp, h_cp, s_cp) == h_cp:
        ans += amari*h*2
    elif min(q_cp, h_cp, s_cp) == s_cp:
        ans += amari*s
print(int(ans))

Submission status: Wrong Answer

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())
q_cp = q*8
h_cp = h*4
s_cp = s*2
d_cp = d
ans = 0
if min(q_cp,h_cp,s_cp,d_cp)==q_cp:
    ans+=n//2*q*8
elif min(q_cp,h_cp,s_cp,d_cp)==h_cp:
    ans+=n/2*h*4
elif min(q_cp,h_cp,s_cp,d_cp)==s_cp:
    ans+=n//2*s*2
else:
    ans += n//2*d
    amari = n%2
    if min(q_cp, h_cp, s_cp) == q_cp:
        ans += amari*q*4
    elif min(q_cp, h_cp, s_cp) == h_cp:
        ans += amari*h*2
    elif min(q_cp, h_cp, s_cp) == s_cp:
        ans += amari*s

print(int(ans))

Submission status: Wrong Answer

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())
q_cp = q*8
h_cp = h*4
s_cp = s*2
d_cp = d
ans = 0
if min(q_cp,h_cp,s_cp,d_cp)==q_cp:
    ans+=n/0.25*q
elif min(q_cp,h_cp,s_cp,d_cp)==h_cp:
    ans+=n/0.5*h
elif min(q_cp,h_cp,s_cp,d_cp)==s_cp:
    ans+=n*s
else:
    ans += n//2*d
    amari = n%2
    if min(q_cp, h_cp, s_cp) == q_cp:
        ans += amari/0.25*q
    elif min(q_cp, h_cp, s_cp) == h_cp:
        ans += amari/0.5*h
    elif min(q_cp, h_cp, s_cp) == s_cp:
        ans += amari*s

print(int(ans))

Submission status: Wrong Answer

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())
q_cp = q*8
h_cp = h*4
s_cp = s*2
d_cp = d
ans = 0
if min(q_cp, h_cp, s_cp, d_cp) == q_cp:
    ans += n//2*4*q
elif min(q_cp, h_cp, s_cp, d_cp) == h_cp:
    ans += n//2*2*h
elif min(q_cp, h_cp, s_cp, d_cp) == s_cp:
    ans += n//2*s
else:
    ans += n//2*d
    amari = n%2
    if min(q_cp, h_cp, s_cp) == q_cp:
        ans += amari/0.25*q
    elif min(q_cp, h_cp, s_cp) == h_cp:
        ans += amari/0.5*h
    elif min(q_cp, h_cp, s_cp) == s_cp:
        ans += amari*s

print(int(ans))

Submission status: Wrong Answer

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())
q_cp = q*8
h_cp = h*4
s_cp = s*2
d_cp = d
ans = 0
if min(q_cp, h_cp, s_cp, d_cp) == q_cp:
    ans += n//2*4*q
elif min(q_cp, h_cp, s_cp, d_cp) == h_cp:
    ans += n//52*2*h
elif min(q_cp, h_cp, s_cp, d_cp) == s_cp:
    ans += n//2*s
else:
    ans += n//2*d
    amari = n%2
    if min(q_cp, h_cp, s_cp) == q_cp:
        ans += amari/0.25*q
    elif min(q_cp, h_cp, s_cp) == h_cp:
        ans += amari/0.5*h
    elif min(q_cp, h_cp, s_cp) == s_cp:
        ans += amari*s

print(int(ans))

Submission status: Wrong Answer

Solution code:
q,h,s,d=map(int,input().split())
n=int(input())
q_cp=q/0.25
h_cp=h/0.5
s_cp=s
d_cp=d/2
ans=0
if min(q_cp,h_cp,s_cp,d_cp)==q_cp:
    ans+=n/0.25*q
elif min(q_cp,h_cp,s_cp,d_cp)==h_cp:
    ans+=n/0.5*h
elif min(q_cp,h_cp,s_cp,d_cp)==s_cp:
    ans+=n*s
else:
    ans+=n//2*d
    n=(n-n//2*2)
    if min(q_cp,h_cp,s_cp)==q_cp:
        ans+=n/0.25*q
    elif min(q_cp,h_cp,s_cp)==h_cp:
        ans+=n/0.5*h
    elif min(q_cp,h_cp,s_cp)==s_cp:
        ans+=n*s

print(int(ans))

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc019/tasks/agc019_a

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

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

Submission status: Wrong Answer

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

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

n = int(input())

if n % 2 == 0:
    print(n * min(q, h, s, d))
else:
    tmp = min(q, h, s)
    if n > 1 and d < tmp:
        print((n - 1) * d + tmp)
    else:
        print(n * tmp)

Submission status: Wrong Answer

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

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

n = int(input())

if n % 2 == 0:
    print(n * min(q, h, s, d))
else:
    tmp = min(q, h, s)
    if d < tmp:
        print((n - 1) * d + min(q, h, s))
    else:
        print(n * tmp)

Submission status: Wrong Answer

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

ans = 0

while N > 0:
  div = N // 2
  if N >= 2:
    ans += min(8 * Q,4 * H,2 * S ,D) * div
    N = N % 2 
  else:
    ans += min(4 * Q,2 * H,S)
    N -= 1
    
print(int(ans))

Submission status: Wrong Answer

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

ans = 0

while N > 0:
  div = N // 2
  if N >= 2:
    #print(N,div)
    ans += min(8 * Q,4 * H,2 * S ,D) * div
    N = N % 2 
  else:
    #print(N)
    if N >= 1:
      ans += min(4 * Q,2 * H,S)
      N -= 1
    elif N >= 0.5:
      ans += min(2 * Q,H)
      N -= 0.5
    else:
      ans += Q
      N -= 0.25
    
print(int(ans))

Submission status: Wrong Answer

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

ans = 0

while N > 0:
  div = N // 2
  if N >= 2:
    #print(N,div)
    ans += min(8 * Q,4 * H,2 * S ,D) * div
    N -= 2 * div
  else:
    #print(N)
    if N >= 1:
      ans += min(4 * Q,2 * H,S)
      N -= 1
    elif N >= 0.5:
      ans += min(2 * Q,H)
      N -= 0.5
    else:
      ans += Q
      N -= 0.25
    
print(int(ans))

Submission status: Wrong Answer

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

ans = 0

while N > 0:
  if N >= 2:
    div = N // 2
    ans += min(8 * Q,4 * H,2 * S ,D) * div
    N -= 2 * div
  elif N >= 1:
    ans += min(8 * Q,4 * H,2 * S) / 2
    N -= 1
  elif N >= 0.5:
    ans += min(8 * Q,4 * H) / 4
    N -= 0.5
  else:
    ans += Q
    N -= 0.25
    
print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

x = sorted([(q//0.25, 0.25), (h//0.5, 0.5), (s, 1), (d//2, 2)])
m = 0
ans = 0

for i in range(4):
    if n//x[i][1]!=0:
        n,m = n//x[i][1], n%x[i][1]
        ans += n*x[i][0]*x[i][1]
        n = m
    else:
        continue
print(int(ans))

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    q, h, s, d = map(int, input().split())
    n = int(input())
    t = min(q // 0.25, h // 0.5, s)

    if n == 1:
        print(int(t))
    else:
        if n % 2 == 0:
            print(int(min(t * n, d * n // 2)))
        else:
            print(int(min(t * n, d * ((n - 1) // 2) + t)))


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    q, h, s, d = map(int, input().split())
    n = int(input())
    t = min(q // 0.25, h // 0.5, s)

    if n == 1:
        print(int(t))
    else:
        if n % 2 == 0:
            print(int(min(t * n, d * n // 2)))
        else:
            print(int(min(t * n, d * (n - 1) // 2 + t)))


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    q, h, s, d = map(int, input().split())
    n = int(input())
    t = min(q // 0.25, h // 0.5, s)

    if n == 1:
        print(t)
    else:
        if n % 2 == 0:
            print(min(t * n, d * n // 2))
        else:
            print(min(t * n, d * (n - 1) // 2 + t))


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    if n % 2 == 0:
        q = q * n / 0.25
        h = h * n / 0.5
        s = s * n
        d = d * n / 2
        print(int(min(q, h, s, d)))
    else:
        if n > 1:
            x = n - 1
            qx = q * x / 0.25
            hx = h * x / 0.5
            sx = s * x
            dx = d * x / 2
            q = q / 0.25
            h = h / 0.5
            s = s
            res = f_inf
            for i in [qx, hx, sx, dx]:
                for j in [q, h, s]:
                    res = min(res, i + j)
            print(int(res))
        else:
            q = q / 0.25
            h = h / 0.5
            s = s
            print(int(min(q, h, s)))


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

Q, H, S, D = lr()
N = ir()

N = N * 4
cost = [2 << 31 for _ in range(N+1)]
cost[0] = 0
for n in range(N+1):
    if n >= 1:
        cost[n] = cost[n-1] + Q
    if n >= 2:
        cost[n] = min(cost[n], cost[n-1] + H)
    if n >= 4:
        cost[n] = min(cost[n], cost[n-4] + S)
    if n >= 8:
        cost[n] = min(cost[n], cost[n-8] + D)

print(cost[N])

Submission status: Wrong Answer

Solution code:
*l, n = map(int, open(0).read().split())
c = 0
for i, j in sorted([j*2**(2-i), 2**(i-2)] for i, j in enumerate(l)):
  t = n//j*j
  c += i*t
  n -= t
  if not n:
    print(int(c))
    exit()

Submission status: Wrong Answer

Solution code:
*l, n = map(int, open(0).read().split())
c = 0
for i, j in sorted([j*2**(2-i), 2**(i-2)] for i, j in enumerate(l)):
  t = n//j*j
  c += i*t
  n -= t
  if not n:
    print(c)
    exit()

Submission status: Wrong Answer

Solution code:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
Q,H,S,D = map(int,input().split())
N = int(input())

ltl_1 = min(4*Q,2*H,S)
lit_2 = min(2*S,D)
num1 = N%2
num2 = N//2

ans = num2 * lit_2 + num1 * ltl_1
print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

Submission status: Wrong Answer

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

cost = [q, min(q*2,h), min(q*4,h*2,s), min(q*8,h*4,s*2,d)]

nedan = 0
for i, c in enumerate(cost[::-1]):
  x = n // (2 ** (-i+1))
  n -= x * (2 ** (-i+1))
  nedan += x * c

print(int(nedan))

Submission status: Wrong Answer

Solution code:
q,h,s,d = map(int,input().split())
n = int(input())
p = []
p.append([q*8,q,0.25])
p.append([h*4,h,0.5])
p.append([s*2,s,1])
p.append([d,d,2])
p.sort()
ans = 0

for i in range(4):
    if n%p[i][2] == 0:
        ans += n//p[i][2]*p[i][1]
        print(int(ans))
        exit()
    else:
        ans += n//p[i][2]*p[i][1]
        n %= p[i][2]

Submission status: Wrong Answer

Solution code:
Q,H,S,D=map(int,input().split())
o=Q*8;h=H*4;s=S*2;d=D
N=int(input())
A=[0]*4;p=0;q=N
 
A=[[0.25,Q,o],[0.5,H,h],[1,S,s],[2,D,d]]
A.sort(key=lambda x: x[2])
 
#print(A)
 
i=0
while  q>0:
  if q%A[i][0]==0:
    p=p+(q//A[i][0])*A[i][1]
    q=q-(q//A[i][0])*A[i][0]
    break
  else:
    p=p+(q//A[i][0])*A[i][1]
    q=q-(q//A[i][0])*A[i][0]
    i=i+1
 
print(int(p))

Submission status: Wrong Answer

Solution code:
Q, H, S, D = list(map(int, input().split()))
Q *= 8
H *= 4
S *= 2
A = min(Q, H, S, D)
B = min(Q, H, S) / 2
N = int(input())

print(int(N//2*A+N%2*B))

Submission status: Wrong Answer

Solution code:
Q, H, S, D = list(map(int, input().split()))
Q *= 8
H *= 4
S *= 2
A = min(Q, H, S, D)
B = min(Q, H, S)
N = int(input())

print(int(N/2*A+N%2*B))

Submission status: Wrong Answer

Solution code:
Q, H, S, D = list(map(int, input().split()))
Q *= 8
H *= 4
S *= 2
A = min(Q, H, S, D)
N = int(input())

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

Submission status: Wrong Answer

Solution code:
from sys import stdin

q, h, s, d = map(int, stdin.readline().rstrip().split())
n = int(stdin.readline().rstrip())
q *= 4
h *= 2
t = min(q, h, s)
if 2 * t > d:
    print((n // 2) * d + t)
else:
    print(n * t)

Submission status: Wrong Answer

Solution code:
from sys import stdin

q, h, s, d = map(int, stdin.readline().rstrip().split())
n = int(stdin.readline().rstrip())
q *= 4
h *= 2
t = min(q, h, s)
if 2 * t > h:
    print((n // 2) * d + t)
else:
    print(n * t)

Submission status: Wrong Answer

Solution code:
Q, H, S, D = list(map(int, input().split()))
H /= 2
S /= 4
D /= 8
A = min(Q, H, S, D)
N = int(input())

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

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
from operator import itemgetter
def main():
    q,h,s,d=map(int,input().split())
    n=int(input())
    weight=[(0.25,q,q/0.25),(0.5,h,h/0.5),(1,s,s),(2,d,d/2)]
    weight.sort(key=itemgetter(2))
    cost=0
    for w in weight:
        kosu=n//w[0]
        cost+=int(w[1]*kosu)
        n-=w[0]*kosu
        print(w[1],kosu)
    print(cost)
if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
from operator import itemgetter
def main():
    q,h,s,d=map(int,input().split())
    n=int(input())
    weight=[(0.25,q,q/0.25),(0.5,h,h/0.5),(1,s,s),(2,d,d/2)]
    weight.sort(key=itemgetter(2))
    cost=0
    for w in weight:
        cost+=w[1]*(n//w[0])
        n-=w[0]*(n//w[0])
    print(int(cost))
if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
n = int(input())
b = [[a[i]/(0.25 * 2**i), a[i], 0.25 * 2**i] for i in range(4)]
b.sort()
ans = 0
for i in range(4):
    if b[i][2] <= n:
        tmp = n//b[i][2]
        n -= b[i][2]*tmp
        ans += b[i][1]*tmp
print(int(ans))

Submission status: Wrong Answer

Solution code:
Q,H,S,D=map(int,input().split())
o=Q*8;h=H*4;s=S*2;d=D
N=int(input())
A=[0]*4;p=0;q=N

A=[[0.25,Q,o],[0.5,H,h],[1,S,s],[2,D,d]]
A.sort(key=lambda x: x[2])

#print(A)

i=0
while  q>0:
  if q%A[i][0]==0:
    p=p+(q//A[i][0])*A[i][1]
    q=q-(q//A[i][0])*A[i][0]
    break
  else:
    p=p+(q//A[i][0])*A[i][1]
    q=q-(q//A[i][0])*A[i][0]
    i=i+1

print(p)

Submission status: Wrong Answer

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

ans = 0
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: Wrong Answer

Solution code:
import heapq
from collections import defaultdict, deque
from math import ceil, factorial
from fractions import gcd
import sys

sys.setrecursionlimit(10 ** 7)
INF = float("inf")
MOD = 10 ** 9 + 7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))


Q, H, S, D = mii()
N = ii()

tea = [
    (Q, 0.25, Q * 8),
    (H, 0.5, H * 4),
    (S, 1, S * 2),
    (D, 2, D),
]

tea.sort(key=lambda x: x[2])

ans = 0

remaining = N
for i in range(4):
    p, q, _ = tea[i]
    d, v = divmod(remaining, q)
    if d == 0:
        continue
    ans += d * p
    remaining = v

print(int(ans))

Submission status: Wrong Answer

Solution code:
import heapq
from collections import defaultdict, deque
from math import ceil, factorial
from fractions import gcd
import sys

sys.setrecursionlimit(10 ** 7)
INF = float("inf")
MOD = 10 ** 9 + 7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))


Q, H, S, D = mii()
N = ii()

tea = [
    (Q, 0.25),
    (H, 0.5),
    (S, 1),
    (D, 2),
]

tea.sort(key=lambda x: x[0] / x[1])

ans = 0

remaining = N
for i in range(4):
    d, v = divmod(remaining, tea[i][1])
    if d == 0:
        continue
    ans += d * tea[i][0]
    remaining = v

print(int(ans))

Submission status: Wrong Answer

Solution code:
a,b,c,d=map(int,input().split())
n=int(input())
l=[a*4,b*2,c,d/2]
p=min(l)
q=min(l[:3])
print(int(n*min(l)) if n%2==0 or p==q else int((n-1)*(d/2)+q))

Submission status: Wrong Answer

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

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

l = [(0.25, Q, 0.25/Q), (0.5, H, 0.5/H), (1, S, 1/S), (2, D, 2/D)]
l.sort(key=lambda x:x[2], reverse=True)
ans = 0
idx = 0
while N != 0:
	n = N//l[idx][0]
	ans += l[idx][1]*n
	N -= l[idx][0]*n

	idx += 1

print(int(ans))

Submission status: Wrong Answer

Solution code:
import sys
lin = input().split()
q = int(lin[0]) # 0.25l
h = int(lin[1]) # 0.5l
s = int(lin[2]) # 1l
d = int(lin[3]) # 2l
n = int(input()) # 1 <= n <= 1000000000
# 4q = 2h = 1s = 0.5d の価格をもとめる
# 安いもので集める
# dの場合、奇数だったら、4q, 2h, 1sのいずれか
# もっとも安価となるものを選択する。
mod = n % 2
x = n // 2 * 2
min = int(x * d / 2)
if min > x * s:
  min = x * s
if min > x * h * 2:
  min = x * h * 2
if min > x * q * 4:
  min = x * q * 4
mmm = sys.maxsize
if mmm > mod * s:
  mmm = mod * s
if mmm > mod * h * 2:
  mmm = mod * h * 2
if mmm > mod * q * 4:
  mmm = mod * q * 4
print(min + mmm)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
Q, H, S,D = map(int, input().split())
N = int(input())
# Dから順番に使おうとする
# Nを4倍しておこう
N *= 4
cnt = 0
# D > 2*Sなら使わない
if D <= 2 * S and D <= 4*S and D <= 8*Q:
    cnt += N // 8 *  (D)
    N %= 8

# 次、Sを使うかどうか
if S <= 2 * H and S <= 4*Q:
    cnt += N // 4 * (S)
    N %= 4

# 次、Hを使うかどうか
if H <= 2 * Q :
    cnt += N // 2 * (H)
    N %= 2

# 最後
cnt += N * (Q)

print(cnt)

Submission status: Wrong Answer

Solution code:
Q, H, S,D = map(int, input().split())
N = int(input())
# Dから順番に使おうとする
# Nを4倍しておこう
N *= 4
cnt = 0
# D > 2*Sなら使わない
if D < 2 * S and D < 4*S and D < 8*Q:
    cnt += N // 8 *  (D)
    N %= 8

# 次、Sを使うかどうか
if S < 2 * H and S < 4*Q:
    cnt += N // 4 * (S)
    N %= 4

# 次、Hを使うかどうか
if H < 2 * Q :
    cnt += N // 2 * (H)
    N %= 2

# 最後
cnt += N * (Q)

print(cnt)

Submission status: Wrong Answer

Solution code:
Q, H, S,D = map(int, input().split())
N = int(input())
# Dから順番に使おうとする
# Nを4倍しておこう
N *= 4
cnt = 0
# D > 2*Sなら使わない
if D <= 2 * S:
    cnt += N//8 * (D)
    N %= 8
# 次、Sを使うかどうか
if S <= 2 * H:
    cnt += N //4 *(S)
    N %= 4

# 次、Hを使うかどうか
if H <= 2* Q:
    cnt += N //2 *(H)
    N %= 2

# 最後
cnt += N * (Q)

print(cnt)

Submission status: Wrong Answer

Solution code:
p = list(map(int, input().split()))
n = int(input())

l = [min(p[0] * 4, p[1] * 2, p[0] * 2 + p[1], p[2]), p[3]]
ppl = [l[0], l[1] / 2]

if (ppl[0] <= ppl[1]):
    print(n * l[0])
else:
    print((n//2)*l[1] + l[0])

Submission status: Wrong Answer

Solution code:
p = list(map(int, input().split()))
n = int(input())
l = []
s = [0.25, 0.5, 1, 2]

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


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


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

Submission status: Wrong Answer

Solution code:
p = list(map(int, input().split()))
n = int(input())
l = []
s = [0.25, 0.5, 1, 2]

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


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


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