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: Accepted

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())
ans = []
ans.append((n//0.25)*q)
ans.append((n//0.5)*h)
ans.append((n//1)*s)
if n % 2 != 0:
    ans.append((n//2)*d+min(q*4, h*2, s))
else:
    ans.append((n//2)*d)
print(int(min(ans)))

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    a = sorted(list(zip(LI(),[0.25,0.5,1.0,2.0])), key=lambda x: x[0]/x[1])
    n = I() * 4
    r = 0
    for i in range(4):
        k,t = a[i]
        t = int(t*4)
        if n >= t:
            r += k * (n//t)
            n %= t

    return r

print(main())

Submission status: Accepted

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

# UPDATE
H = min(2*Q, H)
S = min(2*H, S)
D = min(2*S, D)

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

Submission status: Accepted

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

for i in xrange(4):
    t = a[i]
    for j in xrange(i + 1, 4):
        t *= 2
        a[j] = min(a[j], t)

ans = 0

for i in xrange(3, -1, -1):
    ans += (n / v[i]) * a[i]
    n %= v[i]

print ans

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding: utf-8

def main():
    q, h, s, d = map(int, input().split())
    n = int(input())
    a = min([4 * q, 2 * h, s])
    if 2 * a <= d:
        return n * a
    else:
        return (n//2) * d + (n % 2) * a


print(main())

Submission status: Accepted

Solution code:
A = []
A = map(int, raw_input().split(' '))
pow = [1, 2, 4, 8]

N = int(raw_input())
N *= 4

for i in range(len(A) - 1):
	A[i + 1] = min(A[i] * 2, A[i + 1])

res = 0
for i in range(len(A) - 1, -1, -1):
	floor = N / pow[i]
	res += floor * A[i]
	N %= pow[i]

print res

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

if 2*S>D:
    cnt_2 = N//2
    cnt_1 = N%2
    pay = a*cnt_2 + S*cnt_1
else:
    pay = N * S
print(pay)

Submission status: Runtime Error

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

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

if 2*S>D:
    cnt_2 = N//2
    cnt_1 = N%2
    pay = a*cnt_2 + S*cnt_1
else:
    pay = N * S
print(int(pay))

Submission status: Runtime Error

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

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

if 2*S>D:
    cnt_2 = N//2
    cnt_1 = N%2
    pay = a*cnt_2 + S*cnt_1
else:
    pay = (N//A) * S
print(int(pay))

Submission status: Runtime Error

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

#2Lあたり
Q1,H1 = 4*Q,2*H
S = min(Q1,H1,S)

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

Submission status: Runtime Error

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

#2Lあたり
Q1,H1,S1 = 8*Q,4*H,2*S
S = min(Q1,H1,S1)

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

Submission status: Runtime Error

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

#2Lあたり
Q1,H1,S1 = 8*Q,4*H,2*S
S = min(Q1,H1,S1)


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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

print(int(ans))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a, b, c, d = map(int, input().split())
n = int(input())
 
b = min(a + a, b)
c = min(b + b, c)
d = min(c + c, d)
 
q, r = divmod(N, 2)
x = q * d + r * c
print(x)

Submission status: Runtime Error

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
Q,H,S,D = IL()
N = ()

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

Submission status: Runtime Error

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

dp = [1<<60] * (N + 2)

dp[0] = 0

for i in range(1, N+1):
    dp[i] = min([dp[i-1] + Q * 4, dp[i-1] + Q*2 + H, dp[i-1] + H*2, dp[i-1] + S])
    if i >= 2:
        dp[i] = min(dp[i], dp[i-2] + D)

print(dp[N])

Submission status: Runtime Error

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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
q, h, s, d = map(int, sys.stdin.readline().rstrip().split())
N = I()
D = d
qh = min(2*q, h)
S = min(2*qh, s)
x = min(2*S, D)
if N%2 == 0:
    print(N//2*x)
else:
    print(N//2*x + S)

Submission status: Runtime Error

Solution code:
a,b,c,d=map(int, input().split)
n=int(input)
oneltr=min(4*a, 2*b, c, 2*a+b)
twoltr=min(8*a, 4*b, 2*c, d, c+2*b, 4*a+2*b)

if n%2==0 :
               print(twoltr*n//2)
else :
               print(oneltr+twoltr*(n-1)//2)

Submission status: Runtime Error

Solution code:
a,b,c,d=map(int, input().split)
n=int(input)
oneltr=min(4*a, 2*b, c, 2*a+b)
twoltr=min(8*a, 4*b, 2*c, d, c+2*b, c+b+2*a,c+4*a,4*a+2*b,b+6*a,3*b+2*a)

if n%2==0 :
               print(twoltr * (n//2))
else :
               print(oneltr+twoltr * ((n-1)//2))

Submission status: Runtime Error

Solution code:
a,b,c,d=map(int, input().split)
n=int(input)
oneltr=min(4*a, 2*b, c, 2*a+b)
twoltr=min(8*a, 4*b, 2*c, d, c+2*b, c+b+2*a,c+4*a,4*a+2*b,b+6*a,3*b+2*a)

if n%2==0 :
               print(twoltr*n//2)
else :
               print(oneltr+twoltr*(n-1)//2)

Submission status: Runtime Error

Solution code:
a,b,c,d=map(int, input().split())
n=int(input)
oneltr=min(4*a, 2*b, c, 2*a+b)
twoltr=min(8*a, 4*b, 2*c, d, c+2*b, c+b+2*a,c+4*a,4*a+2*b,b+6*a,3*b+2*a)

if(n%2==0) :
              print((n//2)*twoltr)
else :
              print(oneltr+((n-1)//2)*twoltr)

Submission status: Runtime Error

Solution code:
a,b,c,d=map(int, input().split)
n=int(input)
oneltr=min(4*a, 2*b, c, 2*a+b)
twoltr=min(8*a, 4*b, 2*c, d, c+2*b, c+b+2*a,c+4*a,4*a+2*b,b+6*a,3*b+2*a)

if n%2==0 :
                  print((n//2)*twoltr)
else :
         print(oneltr+two*(n-1)//2)

Submission status: Runtime Error

Solution code:
a,b,c,d=map(int, input().split)
n=int(input)
oneltr=min(4*a, 2*b, c, 2*a+b)
twoltr=min(8*a, 4*b, 2*c, d, c+2*b, c+b+2*a,c+4*a,4*a+2*b,b+6*a,3*b+2*a)

if(n%2==0) :
                   print(n//2*twoltr)
else :
                    print(oneltr+(n-1)//2*twoltr)

Submission status: Runtime Error

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

h = min(H , 2*Q)
s = min(2*h,S)
d = min(2*s,D)

if N % 2 == 0:
  print((N//2 * d))
else:
  print((N//2)*d + s)

Submission status: Runtime Error

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

h = min(H , 2*Q)
s = min(2*h,S)
d = min(2*s,D)

print((N//2)*d + (N%2)*s)

Submission status: Runtime Error

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

h = min(2*Q,H)
s = min(2*h,S)
d = min(2*s,D)

print((N//2)*d + (N%2)*s)

Submission status: Runtime Error

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

list_1 = [S, 2*H, 4*D]
list_1.sort()

min_1 = list[0]

if D < (min_1 * 2):
  total_cost = D * (N // 2) + min_1 * (N % 2)
else:
  total_cost = min_1 * N

print(total_cost)

Submission status: Runtime Error

Solution code:
print((n // 2) * min(8 * q, 4 * h, 2 * s, d) + (n % 2) * min(4 * q, 2 * h, s))

Submission status: Runtime Error

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())
n4 = n * 4
# jリットルになるようにしたi番目までの総和最小値
# dp[i][j] = 
w = [1, 2, 4, 8]
v = [q, h, s, d]
dp = [[10**8+1]*(n4+1) for i in range(4)]
for i in range(4):
  dp[i][0] = 0
for i in range(4):
  for j in range(n4+1):
    if j >= w[i] and i >= 1:
      dp[i][j] = min(dp[i-1][j], dp[i][j-w[i]] + v[i])
    else:
      dp[i][j] = dp[i-1][j]
print(dp[3][n4])

Submission status: Runtime Error

Solution code:
q, h, s, d = map(int, input().split())
n = int(input())
n4 = n * 4
# jリットルになるようにしたi番目までの総和最小値
# dp[i][j] = 
w = [1, 2, 4, 8]
v = [q, h, s, d]
dp = [[10**9]*(n4+1) for i in range(4)]
for i in range(4):
  dp[i][0] = 0
for i in range(4):
  for j in range(n4+1):
    if j >= w[i]:
      dp[i][j] = min(dp[i-1][j], dp[i][j-w[i]] + v[i])
    else:
      dp[i][j] = dp[i-1][j]
print(dp[3][n4])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())

PS = [[Q * 4, 0.25], [H * 2, 0.5], [S, 1], [D / 2, 2]]

PS.sort(key=lambda x: x[0])

# print(PS)

R = N
ans = 0
for i in range (4):
    if R == 0:
        break
    elif R >= PS[i][1]:
        ans += PS[i][0] * PS[i][1] * (R // PS[i][1])
        R = R % PS[i][1]
    # print("ans :", ans)

print(int(ans))

Submission status: Runtime Error

Solution code:
def main(q: int, h: int, s: int, d: int, n: int):
    print((n // 2) * min(q * 8, h * 4, s * 2, d) + (n % 2) * min(q * 4, h * 2, s))


if __name__ == "__main__":
    q, h, s, d = map(int, input().split())
    n = int(input)

    main(q, h, s, d, n)

Submission status: Runtime Error

Solution code:
price=list[map(int,input().split())]
k=[0.25,0.5,1.0,2.0]

N=int(input())

from itertools import permutations
ans=float("Inf")
for x in permutations([0,1,2,3]):
  tmp=0
  n=N
  for y in x:
    tmp+= (n//k[y])*price[y]
    n=n%k[y]
  ans=min(tmp,ans)
  
print(ans)

Submission status: Runtime Error

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

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

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

most_bargain = min(8 * Q, 4 * H, 2 * S, D)
if most_bargain != D:
    print((most_bargain // 2) * N)
else:
    if N % 2 == 0:
        print((N // 2) * D)
    else:
        print((N // 2) * D + min(4 * Q, 2 * H, S))5410760474836152
1524157763907942

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
VS = [(Y, Y*(2/q), q) for Y, q in ((int(input()), q) for q in (0.25, 0.5, 1, 2))]
N = int(input())
tanka = 0
for Y, _, q in sorted(VS, key=lambda x:x[1], reverse=True):
  u = N // q
  N -= q * u
  tanka += Y * u
  if N <= 0:
    break

print(tanka)

Submission status: Runtime Error

Solution code:
Q,H.S,D=input().split()
N=input()
answer=(N/2) × min(8 ∗ Q, 4 ∗ H, 2 ∗ S, D) + (N mod 2) × min(4 ∗ Q, 2 ∗ H, S).
print(answer)

Submission status: Runtime Error

Solution code:
answer=1000000000
q,h,s,d=input().split()
n=int(input())
qq=int(n/0.25)
hh=int(n/0.5)
ss=int(n)
dd=int(n/2)
i[0]=qq*q
i[1]=hh*h
i[2]=ss*s
i[3]=dd*d
for s in range(3):
  if answer > i[s] :
    answer=i[s]
    
print(answer)

Submission status: Runtime Error

Solution code:
answer=1000000000
q,h,s,d=int(input().split())
n=int(input())
qq=int(n/0.25)
hh=int(n/0.5)
ss=int(n)
dd=int(n/2)
i[0]=qq*q
i[1]=hh*h
i[2]=ss*s
i[3]=dd*d
for s in range(3):
  if answer > i[s] :
    answer=i[s]
    
print(answer)

Submission status: Runtime Error

Solution code:
import bisect
import sys
from math import atan
def lis(L):
    if not L:
        return 0
    seq = [L[0]]
    for i in L[1:]:
        if seq[-1] < i:
            seq.append(i)
        else:
            seq[bisect.bisect_left(seq, i)] = i
    return len(seq)

def mhd(x, y):
    return abs(x) + abs(y)

x1, y1, x2, y2 = map(int, sys.stdin.readline().split())
        
N = int(sys.stdin.readline())

if x1 == x2 or y1 == y2:
    if x1 == x2:
        if y1 > y2:
            y1, y2 = y2, y1
        for _ in range(N):
            X, Y = map(int, sys.stdin.readline().split())
            if X != x1:
                continue
            else:
                if y1 <= Y <= y2:
                    print(100*mhd(0, y1-y2) - 20 + 40*atan(1))
                    sys.exit()
                else:
                    print(100*mhd(0, y1-y2))
                    sys.exit()
    else:
        if x1 > x2:
            x1, x2 = x2, x1
        for _ in range(N):
            X, Y = map(int, sys.stdin.readline().split())
            if Y != y1:
                continue
            else:
                if x1 <= X <= x2:
                    print(100*mhd(x1-x2, 0) - 20 + 40*atan(1))
                    sys.exit()
                else:
                    print(100*mhd(x1-x2, 0))
                    sys.exit()
if x1 > x2:
    x1, x2 = x2, x1
    y1, y2 = y2, y1

geta = 10**9+7
B = []
if y1 < y2:
    for _ in range(N):
        X, Y = map(int, sys.stdin.readline().split())
        if x1 <= X <= x2 and y1 <= Y <= y2:
            B.append(X*geta + Y)
    B.sort()
    B = [b%geta for b in B]
    lb = lis(B)
    if lb == min(abs(x1-x2), abs(y1-y2)) + 1:
        print(100*mhd(x1-x2, y1-y2) + (lb-1)*(20*atan(1)-20) + 40*atan(1) - 20)
    else:
        print(100*mhd(x1-x2, y1-y2) + lb*(20*atan(1)-20))
    
else:
    for _ in range(N):
        X, Y = map(int, sys.stdin.readline().split())
        if x1 <= X <= x2 and y2 <= Y <= y1:
            B.append(X*geta - Y)
    B.sort()
    B = [b%geta for b in B]
    lb = lis(B)
    if lb == min(abs(x1-x2), abs(y1-y2)) + 1:
        print(100*mhd(x1-x2, y1-y2) + (lb-1)*(20*atan(1)-20) + 40*atan(1) - 20)
    else:
        print(100*mhd(x1-x2, y1-y2) + lb*(20*atan(1)-20))

Submission status: Runtime Error

Solution code:
q,h,s,d = map(int,input().split())
r = [q,h,s,d]
n = int(input())*4
l = [q,h/2,s/4,d/8]
v = [1,2,4,8]
cost = 0
while n:
  now = l2.index(min(l))
  cost += n//v[now] * r[now]
  n %= v[now]
  v.pop(now)
  r.pop(now)
  l.pop(now)
print(cost)

Submission status: Runtime Error

Solution code:
q,h,s,d = map(int,input().split())
r = [q,h,s,d]
n = int(input())
l = [q,h/2,s/4,d/8]
cost = 0
while n:
  now = l2.index(min(l))
  cost += n//r[now]
  n %= r[now]
  r.pop(now)
  l.pop(now)
print(cost)

Submission status: Runtime Error

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

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

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

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

print(int(cost))

Submission status: Runtime Error

Solution code:
x1,y1,x2,y2=map(int,input().split())
fx=1
fy=1
if x1>x2:
	x1,x2=x2,x1
	fx=-1
if y1>y2:
	y1,y2=y2,y1
	fy=-1

n=int(input())
p=[]
for i in range(n):
	x,y=map(int,input().split())
	if x1<=x<=x2 and y1<=y<=y2:
		p.append((fx*x,fy*y))
p=[y for x,y in sorted(p)]

from bisect import bisect_left as bl

b=[]

for y in p:
	pos=bl(b,y)
	if len(b)<=pos:
		b.append(y)
	else:
		b[pos]=y
	
from math import pi

l=len(b)

if l==min(x2-x1,y2-y1)+1:
	print(100*(x2-x1+y2-y1)+(5*pi-20)*(l-1)+(10*pi-20))
else:
	print(100*(x2-x1+y2-y1)+(5*pi-20)*l);

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def main():
    rt = 0
    Q,H,S,D = map(int,input())
    N = float(input())
    count_1 = N//2
    count_2 = (N-count_1)//1
    count_3 = (N-count_1-count_2)*100//50
    count_4 = (((N-count_1-count_2)*100)-50*count_3)//25
    if count_1:
       rt+=count_1*min(2*S,D,4*H,8*Q)
    if count_2:
        rt+=count_2*min(S,2*H,4*Q)
    if count_3:
        rt+=min(2*H,Q)*count_3
    if count_4:
        rt+=Q*count_4
    print(rt)

if __name__=="__main__":
    main()

Submission status: Runtime Error

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

import pulp

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

problem = pulp.LpProblem('iceteastore', pulp.LpMinimize)
a = pulp.LpVariable('Qa', lowBound=0, cat='Integer')
b = pulp.LpVariable('Hb', lowBound=0, cat='Integer')
c = pulp.LpVariable('Sc', lowBound=0, cat='Integer')
d = pulp.LpVariable('Dd', lowBound=0, cat='Integer')
problem += (Q * a) + (H * b) + (S * c) + (D * d)
problem += a>= 0
problem += b>= 0
problem += c>= 0
problem += d>= 0
problem += (0.25 * a) + (0.5 * b) + (1.0 * c) + (2.0 * d) == N
status = problem.solve()

#print(pulp.LpStatus[status])

cost = int((Q * a.value()) + (H * b.value()) + (S * c.value()) + (D * d.value()))
print(cost)

Submission status: Runtime Error

Solution code:
l = map(int, raw_input().split())
N = raw_input
l[0] = Q
l[1] = H
l[2] = S
l[3] = D
if Q*2 > H:
    M1 = H
else:
    M1 = Q*2

if  M1*2 > S:
    M = S
else:
    M = M1*2
if M*2 < D:
    print(M*N)
else:
    if N%2 == 0:
        print(D*(N//2))
    else:
        print(D*(N//2) + M)

Submission status: Runtime Error

Solution code:
Q, H, S, D, N = input(), input(), input(), input(), input()
if Q*2 > H:
    M1 = H
else:
    M1 = Q*2

if  M1*2 > S:
    M = S
else:
    M = M1*2
if M*2 < D:
    print(M*N)
else:
    if N%2 == 0:
        print(D*(N//2))
    else:
        print(D*(N//2) + M)

Submission status: Runtime Error

Solution code:
from math import pi

input1 = list(map(int,input("").split(" ")))
N = int(input(""))
src = {"x":input1[0],"y":input1[1]}
dist = {"x":input1[2],"y":input1[3]}

spring = []
for i in range(N):
	temp = list(map(int,input("").split(" ")))
	if temp[0] in range(min(src['x'],dist['x']),max(src['x'],dist['x'])+1):
		if temp[1] in range(min(src['y'],dist['y']),max(src['y'],dist['y'])+1):
			spring.append({'x':temp[0], 'y':temp[1]})

# print(spring)
path = (abs(src['x']-dist['x']) + abs(src['y']-dist['y'])) * 100
if len(spring) > 0:
	r = 10
	if src['x'] == dist['x'] or src['y'] == dist['y'] :
		#半円
		path += r*pi - 2*r 
	else:
		#1/4円
		if (src['x']-dist['x'])*(src['y']-dist['y']) > 0:
			spring.sort(key=lambda k: k['x'])
		else:
			spring.sort(key=lambda k: k['x'], reverse=True)
		L = [spring[0]['y']]
		length = 1
		for i in range(1,len(spring)):
			if L[length-1] < spring[i]['y']:
				L.append(spring[i]['y'])
				length += 1
			else:
				for j in range(length):
					if spring[i]['y'] <= L[j]:
						L[j] = spring[i]['y']
						break
		path += (r*pi/2 - 2*r) * length

print(path)

Submission status: Runtime Error

Solution code:
#get parameters
Qc, Hc, Sc, Dc = map(int, input().split())
Nv = input()
Nc = 0
# creat lists
Volumes = [0.25,0.50,1.00,2.00]
Costs = [Qc, Hc, Sc, Dc]
V_ = Nv
Number_bottles = [0,0,0,0]

for i in range(len(Volumes)):

	Number_bottles[i] = V_//Volumes[i]
	V_ = Volumes[i] * Number_bottles[i]

for i in range(len(Volumes)):
	
	Nc +=  Number_bottles[i] * Costs[i]

print (Nc)

Submission status: Runtime Error

Solution code:
import math 

if __name__ == '__main__':
    Q, H, S, D = map(int, input().split())
    N = int(input())
    q, h ,s ,d = [0.25, 0.5, 1, 2]
    cost_d = math.inf
    cost_s = math.inf
    cost_h = math.inf
    cost_q = math.inf
    if N > d:
        N_d=N
        while N_d > d:
            N_d -= d
            cost_d += D
        while N_d > s:
            N_d -= s
            cost_d += S
        while N_d > h:
            N_d -= h
            cost_d += H
        while N_d  > 0:
            N_d -= q
            cost_d += Q
    elif N > s:
        N_s = N
        while N_s > s:
            N_s -= s
            cost_s += S
        while N_s > h:
            N_s -= h
            cost_s += H
        while N_s > 0:
            N_s -= q
            cost_s += Q
    elif N > h:
        N_h = N 
        while N_h > h:
            N_h -= h
            cost_h += H
        while N_h > 0:
            N_h -= q
            cost_h += Q
    else:
        N_q = N
        while N_q > 0:
            N_q -= q
            cost_q += Q
    ans = min(cost_d, cost_s, cost_h, cost_q)
    print(ans)

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
    Q, H, S, D = map(int, input().split())
    N = int(input())
    q, h ,s ,d = [0.25, 0.5, 1, 2]
    cost_d = 0
    cost_s = 0
    cost_h = 0
    cost_q = 0
    if N > d:
        N_d=N
        while N_d > d:
            N_s -= d
            cost_d += D
        while N_d > s:
            N_s -= s
            cost_d += S
        while N_d > h:
            N_s -= h
            cost_d += H
        while N_d  > 0:
            N_s -= q
            cost_d += Q
    elif N > s:
        N_s = N
        while N_s > s:
            N_s -= s
            cost_s += S
        while N_s > h:
            N_s -= h
            cost_s += H
        while N_s > 0:
            N_s -= q
            cost_s += Q
    elif N > h:
        N_h = N 
        while N_h > h:
            N_h -= h
            cost_h += H
        while N_h > 0:
            N_h -= q
            cost_h += Q
    else:
        N_q = N
        while N_q > 0:
            N_q -= q
            cost_q += Q
    ans = min(cost_d, cost_s, cost_h, cost_q)
    print(ans)