Problem:


Score: 300 points

Problem Statement

In 2028 and after a continuous growth, AtCoder Inc. finally built an empire with six cities (City 1, 2, 3, 4, 5, 6)!

There are five means of transport in this empire:

Train: travels from City 1 to 2 in one minute. A train can occupy at most A people.

Bus: travels from City 2 to 3 in one minute. A bus can occupy at most B people.

Taxi: travels from City 3 to 4 in one minute. A taxi can occupy at most C people.

Airplane: travels from City 4 to 5 in one minute. An airplane can occupy at most D people.

Ship: travels from City 5 to 6 in one minute. A ship can occupy at most E people.

For each of them, one vehicle leaves the city at each integer time (time 0, 1, 2, ...).

There is a group of N people at City 1, and they all want to go to City 6.

At least how long does it take for all of them to reach there? 
You can ignore the time needed to transfer.  

Constraints

1 \leq N, A, B, C, D, E \leq 10^{15}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A
B
C
D
E

Output

Print the minimum time required for all of the people to reach City 6, in minutes.

Sample Input 1

5
3
2
4
3
5

Sample Output 1

7

One possible way to travel is as follows.
First, there are N = 5 people at City 1, as shown in the following image:

In the first minute, three people travels from City 1 to City 2 by train. Note that a train can only occupy at most three people.

In the second minute, the remaining two people travels from City 1 to City 2 by train, and two of the three people who were already at City 2 travels to City 3 by bus. Note that a bus can only occupy at most two people.

In the third minute, two people travels from City 2 to City 3 by train, and another two people travels from City 3 to City 4 by taxi.

From then on, if they continue traveling without stopping until they reach City 6, all of them can reach there in seven minutes.

There is no way for them to reach City 6 in 6 minutes or less.

Sample Input 2

10
123
123
123
123
123

Sample Output 2

5

All kinds of vehicles can occupy N = 10 people at a time.
Thus, if they continue traveling without stopping until they reach City 6, all of them can reach there in five minutes.  

Sample Input 3

10000000007
2
3
5
7
11

Sample Output 3

5000000008

Note that the input or output may not fit into a 32-bit integer type.



Sample input:
5
3
2
4
3
5


Sample output:
7

Submission status: Runtime Error

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

import math

x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a.sort()
b.sort()
c.sort()

cnum = []

takadaka = math.ceil(k ** 0.75)

for i in range(min(takadaka,x)):
    for j in range(min(takadaka,y)):
        for l in range(min(takadaka,z)):
            cnum.append(a[i] + b[j] + c[l])

cnum.sort()
cnum.reverse()

for i in range(k):
    print(cnum[i])

Submission status: Runtime Error

Solution code:
import math

n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

L = [n,0,0,0,0]
num = 0
while True:
  if L[0] > a:
    L[0] -= a
    a_ = a
  else:
    a_ = L[0]
    L[0] = 0
  if L[1] > b:
    L[1] -= b
    b_ = b
  else:
    b_ = L[1]
    L[1] = 0
  if L[2] > c:
    L[2] -= c
    c_ = c
  else:
    c_ = L[2]
    L[2] = 0
  if L[3] > d:
    L[3] -= d
    d_ = d
  else:
    d_ = L[3]
    L[3] = 0
  if L[4] > e:
    L[e] -= e
    e_ = e
  else:
    e_ = L[4]
    L[4] = 0
  L[1] += a_
  L[2] += b_
  L[3] += c_
  L[4] += d_
  num += 1
  if sum(L) == 0:
    break
print(num)

Submission status: Runtime Error

Solution code:
N = int(input())
A[0] = int(input())
A[1] = int(input())
A[2] = int(input())
A[3] = int(input())
A[4] = int(input())
mi = 0
mA = 1e16
for i in range(5):
    if (A[i] < mA):
        mA = A[i]
        mi = i
print((N // A[mi]) + (5 - mi) + mi)

Submission status: Runtime Error

Solution code:
n = int(input())
a = []
for i in range(5):
    inp = int(input())
    a.append(inp)

mini = min(a)
if n > mini:
    add = (int(n /10)*10) / mini
    n -= int(add*mini)
    #print(n)
num = [n]

for i in range(5):
    num.append(0)
    
count =0
while True:
    non_zero = [i for i in range(5) if num[i] !=0] 
    #print(non_zero)
    for i in reversed(non_zero):
        #print("i {}".format(i))
        move = min(a[i], num[i])
        num[i] -= move
        num[i+1] += move
    count +=1
   
    #print(num)
    #print(count)
    if num[-1]==n:
        break
print(int(count+add))

Submission status: Runtime Error

Solution code:
N = int(input())
norimono = []
for _ in range(5):
  norimono.append(int(input()))
  
if 
print((N-1) // min(norimono) + 5)

Submission status: Runtime Error

Solution code:
N = int(input())
transporter = [0]*5
transporter_lag = [0]*5
for i in range(5):
    transporter[i] = int(input())
for i in range(1,5):
    if transporter[i] >= transporter[i-1]:
        transporter_lag[i] = 0
    else :
        transporter_lag[i] = math.ceil(transporter[i-1]/transporter[i]) - 1
if math.ceil(N/transporter[0]) <= 5:
    ans = 5+ sum(transporter_lag)
else :
    ans = math.ceil(N/transporter[0]) + sum(transporter_lag) + 4
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
P = []
for i in range(5):
    P.append(int(input
if N == min(P):
    print(5)
else:
    print(N // min(P) + 5)

Submission status: Runtime Error

Solution code:
a=int(input())
b=[]
for i in range(5):
  b.append(int(input()))
key=min(b)
res=4
t=math.ceil(a/key)
res+=t

Submission status: Runtime Error

Solution code:
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
aa=[]
aa.append(a)
aa.append(b)
aa.append(c)
aa.append(d)
aa.append(e)

coun = [0 for i in range(6)]

coun[0] = n
time = 0
people = n
for i in range(5):
    if(people % aa[i] == 0):
        time += (people // aa[i])
    else:
        time += ((people // aa[i])+1)
    peo = people-people%aa[i]
    people = people%aa[i]
    if(i != 4):
        if(peo - (time-1)*a[i+1]>0):
            people += (peo - (time-1)*a[i+1])


print(time)

Submission status: Runtime Error

Solution code:
def solve():
    num_total = int(input())
    num_transport=[0]*5
    for i in range(5):
        num_transport[i]=int(input())
    time = math.ceil(num_total/num_transport[0])
    x = num_transport[0]
    for i in range(1,5):
        if num_transport[i] < x:
            time = i+ math.ceil(num_total/num_transport[i])
            x = num_transport[i]
        else:
            time += 1
    print(time)

solve()

Submission status: Runtime Error

Solution code:
N = int(input())
A = [0 for i in range(5)]
for i in range(5):
    A[i] = int(input())

if N % min(A) != 0:
    print(N // min(A) + 5)
else
    print(N // min(A) + 4)