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: Wrong Answer

Solution code:
from collections import defaultdict
from string import ascii_uppercase
import sys, bisect
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N = read_int()[0]
cap = [read_int()[0] for _ in range(5)]

def solve():
    b_neck = cap[0]
    b_ni = 0
    ans = 5

    for i in range(5):
        if i == 0:
            wait = N // b_neck
            ans += wait
        if b_neck > cap[i]:
            ans += b_neck // cap[i]
            b_neck = cap[i]
    return ans

if __name__ == "__main__":
    print(solve())

Submission status: Wrong Answer

Solution code:
N = int(input())
moves = [int(input()) for _ in range(5)]
a = min(moves)
lst = [N % a ,0,0,0,0]
ret = N // a

if N % a == 0:
    print(ret)
else:
    print(ret + 5)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

temp=[a,b,c,d,e]
temp.sort()
mini=temp[0]

ans=int(n//mini+5)
if mini>=n:
    print(5)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
saisyo=n+a+b+c+d+e
f=1
g=1
h=1
i=1
j=1
if saisyo>a:
    f=-(-n//a)
    saisyo=a
if saisyo>b:
    g=-(-a//b)
    saisyo=b
if saisyo>c:
    h=-(-b//c)
    saisyo=c
if saisyo>d:
    i=-(-c//d)
    saisyo=d
if saisyo>e:
    saisyo=e
    j=-(-d//e)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

def ceil(n, m):
    if n % m == 0:
        return n / m
    else:
        return int(n / m) + 1

aa = ceil(n, a)
bb = ceil(n, b)
cc = ceil(n, c)
dd = ceil(n, d)
ee = ceil(n, e)

lag = max([aa, bb, cc, dd, ee]) - 1

print(5 + lag)

Submission status: Wrong Answer

Solution code:
N = int(input())
abilities = [int(input()) for _ in range(5)]
min_value = min(abilities)
print(N // min_value + 5)

Submission status: Wrong Answer

Solution code:
import copy
n=int(input())
a=[int(input()) for i in range(5)]

w=sorted(a)

b=[i  for i in range(5)if a[i]==w[0] and (n>a[i] and a[i]!=a[i-1])]
#b=a.index(w[0])
ans=0
m=1
b.append(6)
for i in b:
    ans=ans+i-m
    m=i



x=(n//w[0] if n>w[0] else 0)
m=0
wa=copy.copy(a)
for i in a:
    if m==i:
        wa.remove(i)
    m=i


ans=x*(wa.count(w[0]))+ans
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
num_list = [int(input()) for i in range(5)]

min_num = 0
group_num = 1
member_num = n

for num in num_list:
    if member_num > num:
        split_num = math.ceil(member_num / num)
        if min_num > num:
            split_num -= 1
        group_num = group_num * split_num
        min_num = member_num % num
        member_num = num

if group_num == 1:
    group_num -= 1
print(group_num + 5)

Submission status: Wrong Answer

Solution code:
N = int(input())
abcde = []
for i in range(5):
    abcde.append(int(input()))

box = []
for a in abcde:
    c = N / a
    if N % a != 0:
        c += 1
    box.append(c)

ans = box[0] + 5

for i in range(4):
    if box[0] + i < box[i+1]:
        ans += box[i+1] - (box[0] + i)

print(int(ans) - 1)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
l = []
cnt = 5
min = 0

for i in range(5):
	a = int(input())
	l.append(a)

for i in range(5):
	min = l[0]
	if i == 0 and l[0] < n:
		cnt += n // l[0]
	else:
		if l[i] < min and l[i] < n:
			cnt += math.ceil(n / l[i]) - math.ceil(n / min) 
			min = l[i]

print(cnt)

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 permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, A, B, C, D, E = [INT() for _ in range(6)]
trans = [A, B, C, D, E]
num_city = [N, 0, 0, 0, 0, 0]
time = 0
for i in range(5):
	# print(num_city)
	if i == 0:
		tmp = num_city[0]%A
		num_city[1] = N-tmp
		if N-tmp <= B*(ceil((N/A)-1)):
			num_city[1] = 0
		else:
			num_city[1] -= B*(ceil((N/A)-1))
		num_city[1] += tmp
		num_city[0] = 0
		time += ceil(N/A)

	if i == 1:
		tmp = num_city[1]%B
		num_city[2] = N-tmp
		if N-tmp <= C*((time+(ceil(num_city[1]/B)))-2):
			num_city[2] = 0
		else:
			num_city[2] -= C*((time+(ceil(num_city[1]/B)))-2)
		num_city[2] += tmp
		time += ceil(num_city[1]/B)
		num_city[1] = 0
	if i == 2:
		tmp = num_city[2]%C
		num_city[3] = N-tmp
		if N-tmp <= D*((time+(ceil(num_city[2]/C)))-3):
			num_city[3] = 0
		else:
			num_city[3] -= D*((time+(ceil(num_city[2]/C)))-3)
		num_city[3] += tmp
		time += ceil(num_city[2]/C)
		num_city[2] = 0
	if i == 3:
		tmp = num_city[3]%D
		num_city[4] = N-tmp
		if N-tmp <= E*((time+(ceil(num_city[3]/D)))-4):
			num_city[4] = 0
		else:
			num_city[4] -= E*((time+(ceil(num_city[3]/D)))-4)
		num_city[4] += tmp
		time += ceil(num_city[3]/D)
		num_city[3] = 0
	if i == 4:
		time += ceil(num_city[4]/E)
print(time)

Submission status: Wrong Answer

Solution code:
N = int(input())
l = [int(input()) for i in range(5)]
tmp = 0
for i in range(5):
  if l[i] > N:
    tmp = 1

if tmp == 1:
  print(5)
else:
    ans = 0
    if N%min(l) == 0:
      ans+=5+N//min(l)-1
    else:
      ans+=5+N//min(l)
    print(ans)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
a = list(range(5))
a[0] = int(input())
a[1] = int(input())
a[2] = int(input())
a[3] = int(input())
a[4] = int(input())
b = list(range(5))
tmp = a[0]
b[0] = math.ceil(n/a[0])
c = 0
total = 0
for i in range(1,5):
    if(a[i] >= tmp):
        a[i] = 0
        b[i] = 0
    else:
        b[i] = math.ceil(n/a[i])
for i in range(5):
    b[i] -= (i+1)
    if(b[i]>0):
        total += b[i]
total += 5
print(total)

Submission status: Wrong Answer

Solution code:
import copy
n=int(input())
a=[int(input()) for i in range(5)]

w=sorted(a)

b=[i  for i in range(5)if a[i]==w[0] and (n>a[i] and a[i]!=a[i-1])]
#b=a.index(w[0])
ans=0
m=1
b.append(6)
for i in b:
    ans=ans+i-m
    m=i



x=(n//w[0] if n>w[0] else 0)
m=0
wa=copy.copy(a)
for i in a:
    if m==i:
        wa.remove(i)
    m=i
    print(i,a)

ans=x*(wa.count(w[0]))+ans
print(ans)

Submission status: Wrong Answer

Solution code:
#coding: utf-8
N = int(input())
l = []
pre = 0
ans = 0
for i in range(5):
    l.append(int(input()))
l.append(0)
calc = N
for i in range(5):
    tmp = calc // l[i] + calc % l[i] if calc > l[i] else 1    
    ans += tmp - pre if tmp > pre else 1 
    calc -= pre * l[i + 1]
    pre = tmp
print(ans)

Submission status: Wrong Answer

Solution code:
#n=int(input())
#li=input().split()
#d=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
#import numpy as np
import math
#li=list(map(int,input().split()))
#S=input()

lis=[]
t=[0,0,0,0,0]
ans=0
for i in range(6):
    lis.append(int(input()))

t[0]=math.ceil(lis[0]/lis[1])
ans=t[0]
for i in range(1,5):
    if lis[i+1]>=lis[i]:
        t[i]=t[i-1]
        ans+=1
    else:
        t[i]=math.ceil((lis[0]-lis[i+1]*(t[i-1]-1))/lis[i+1])
        ans+=t[i]


print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

cap = [a, b, c, d, e]
city = [n, 0, 0, 0, 0, 0]

min_pos = 0
for p in range(len(cap)):
    if cap[p] < cap[min_pos]:
        min_pos = p

print(5 + (n // cap[min_pos]))

Submission status: Wrong Answer

Solution code:
inputs = [int(input()) for i in range(6)]
N = inputs[0]
A = inputs[1]
B = inputs[2]
C = inputs[3]
D = inputs[4]
E = inputs[5]

T = 5

def func(T, x, y):
    val = x // y 
    remain = x % y
    T += val
    if remain==0:
        T -= 1
    return T

if A<=B and B<=C and C<=D and D<=E:
    for x,y in zip([N,A,B,C,D],[A,B,C,D,E]):
        T = func(T, x, y)
else:
    for x,y in zip([E,D,C,B,A],[D,C,B,A,N]):
        T = func(T, x, y)

print(T)

Submission status: Wrong Answer

Solution code:
L = [int(input()) for i in range(6)]

cnt = 0
for i in range(5):
    if L[i] <= L[i+1]:
        L[i+1] = L[i]
    else:
        cnt += L[i] // L[i+1]

print(5 + cnt)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

temp=[a,b,c,d,e]
temp.sort()
mini=temp[0]

ans=int(n//mini+5)
if mini==n:
    print(5)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys


def main():
    input = sys.stdin.readline
    n = int(input())
    nin_list = [int(input()) for _ in range(5)]
    num_list = [n / i + 1 if n % i else n / i for i in nin_list]
    print(4 + max(num_list))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
li = []
for i in range(5):
  li.append(int(input()))
k = n//li[0]
c = n//li[0]
d = li[0]
e = n%li[0]
for i in range(1,5):
  if li[i] < d:
    k = (e+(d*c)%li[i])//li[i] + (d*c)//li[i]
    c = n // li[i]
    d = li[i]
    e = n%li[i]
print(c+5)

Submission status: Wrong Answer

Solution code:
li =[int(input()) for i in range(6)]
sum_b=0
for i in range(2,6,1):
    if li[i]<li[1]:
        sum_b+=1
answer= 5 + int(li[0]/li[1])+sum_b*int(li[0]/li[1])
print(answer)

Submission status: Wrong Answer

Solution code:
n,a,b,c,d,e=[int(input()) for i in range(6)]

lis = [a,b,c,d,e]
neck = min(lis)

print(( (n//neck) +1)+4)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

cs = [a,b,c,d,e]

min_idx = cs.index(min(cs))

if min_idx == 0:
    t = int(n / cs[min_idx]) + 1
elif min_idx == 1:
    amari = n % cs[min_idx-1]
    t = int(cs[min_idx-1] / (cs[min_idx-1] - cs[min_idx])) + 1
    if amari <= cs[min_idx]:
        t = t - 1
else:
    amari = cs[min_idx-2] % cs[min_idx-1]
    t = int(cs[min_idx-1] / (cs[min_idx-1] - cs[min_idx])) + 1
    if amari <= cs[min_idx]:
        t = t - 1

print(4 + t)

Submission status: Wrong Answer

Solution code:
#n=int(input())
#li=input().split()
#d=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
#import numpy as np
import math
#li=list(map(int,input().split()))
#S=input()

lis=[]
t=[0,0,0,0,0]
ans=0
for i in range(6):
    lis.append(int(input()))

t[0]=math.ceil(lis[0]/lis[1])
ans=t[0]
print(t[0])
for i in range(1,5):
    if lis[i+1]>=lis[i]:
        t[i]=t[i-1]
        ans+=1
    else:
        t[i]=math.ceil((lis[0]-lis[i+1]*(t[i-1]-1))/lis[i+1])
        ans+=t[i]
    print(t[i])


print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
numbers = [int(input()) for _ in range(5)]
flag = True

for number in numbers:
    if number < N:
        flag = False
        
if flag:
    print(5)

else:
    sum_number = 0
    tunnel = 0
    flag = True
    
    for i in range(len(numbers)-1):
        sum_number += numbers[i]

        if numbers[i+1] < numbers[i]:
            tunnel += 1
        
        if N < sum_number:
            print(5 + tunnel - 1 + N // numbers[0])
            flag = False
            break
            
    if flag:
        print(5 + tunnel + N // numbers[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

cap = [a, b, c, d, e]
city = [n, 0, 0, 0, 0, 0]

min_pos = 0
for p in range(len(cap)):
    if cap[p] < cap[min_pos]:
        min_pos = p

print(5 + n // cap[min_pos])

Submission status: Wrong Answer

Solution code:
N = int(input())
time = []
for i in range(5):
    time.append(int(input()))

print((N // min(time) + 1) - 1 + 5)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(input()) for i in range(5)]
A.sort()
if N<=A[0]:
    print(5)
else:
    block = N//A[0]+1
    if block<6:
        print(block*3+(block-2))
    else:
        print(10+(block-6))

Submission status: Wrong Answer

Solution code:
N = int(input())
min = 0
for i in range(5):
    x = int(input())
    if i == 0:
        min = x
    if min > x :
        min = x
#print("N={} min={}".format(N,min))
if N <= min:
    print(5)
elif N % min == 0:
    print(N >> min + 4)
else:
    print(N // min + 5)

Submission status: Wrong Answer

Solution code:
N = [int(input()) for _ in range(6)]

MinNum = min(N[1:])
Neck = N[0] // MinNum + 1
print(Neck + 4)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

times = np.array(
  [a, b, c, d, e], dtype=np.int64)

min_limit = times.min()

if n % min_limit == 0:
  wait = n/min_limit - 1
else:
  wait = n//min_limit

print(5+wait)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = []
for i in range(5):
    inp = int(input())
    a.append(inp)
mini = min(a)
mini_list = [i for i in range(len(a)) if a[i]==mini]
mini_no = len(mini_list)

if n < mini:
    print(5)
elif mini_no==1 or mini_no==5:
    time = int(n/mini) +1
    print(time+4)
else:
    time = int(n/mini) + (mini_no-1)
    print(time+(5-mini_no))

Submission status: Wrong Answer

Solution code:
n, a, b, c, d, e = [int(input()) for _ in range(6)]
l = [a,b,c,d,e]
ans = 0
city = [n] * 6
# 値が小さくなる点を探す
indmin = 0
for i in range(4):
    if l[i] > l[i + 1]:
        indmin = i + 1
        break
# 値が小さくなるところまでのコスト
ans += indmin
# 値が小さくんなる点が0になるまでのコスト
import math
ans += math.ceil(n / l[indmin])
ans += (5 - (indmin + 1))
if indmin == 4:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
saisyo=n+a+b+c+d+e
f=1
g=1
h=1
i=1
j=1
if saisyo>a:
    f=-(-n//a)
if saisyo>b:
    g=-(-a//b)
if saisyo>c:
    h=-(-b//c)
if saisyo>d:
    i=-(-c//d)
if saisyo>e:
    j=-(-d//e)

goke=f+g+h+i+j

print(goke)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

n = int(input())

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

a.sort()

# print(a)

t = int(n / a[0])
ans = t + 5
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin

N = int(stdin.readline().rstrip())
max_ride = [int(stdin.readline().rstrip()) for _ in range(5)]

add_cnt = 0

for i in range(4):
    if max_ride[i] >= N:
        continue
    tmp = max_ride[i] - max_ride[i+1]
    add_cnt += tmp
    if add_cnt < 0:
        add_cnt = 0

res_time = 5 + N // min(max_ride) + add_cnt

print(res_time)

Submission status: Wrong Answer

Solution code:
atcoder = [int(input()) for i in range(6)]
loc = [atcoder[0],0,0,0,0,0]

ans = 0

num = 1000000000000000000000
for i in range(1,6):
    if atcoder[i] < num:
        num = atcoder[i]

ans2 = atcoder[0] / num
print(int(ans2)+5)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
iList = [int(input()) for i in range(5)]

P1toP2 = math.ceil(N / iList[0])
P2toP3 = math.ceil(iList[0] / iList[1])
P3toP4 = math.ceil(min(iList[:2]) / iList[2])
P4toP5 = math.ceil(min(iList[:3]) / iList[3])
P5toP6 = math.ceil(min(iList[:4]) / iList[4])


print(P1toP2 + P2toP3 + P3toP4 + P4toP5 + P5toP6)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
from string import ascii_uppercase
import sys, bisect
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N = read_int()[0]
cap = [read_int()[0] for _ in range(5)]

def solve():
    b_neck = cap[0]
    b_ni = 0
    for i in range(5):
        if b_neck > cap[i]:
            b_neck = cap[i]
            b_ni = i
    in_neck = N // b_neck
    ans = 5 + in_neck
    return ans

if __name__ == "__main__":
    print(solve())

Submission status: Wrong Answer

Solution code:
from sys import stdin
N=int(stdin.readline().rstrip())
data=[]
for i in range(5):
    data.append(int(input()))
    
ans=(N//sorted(data)[0])+5
if set(data)=={N}:
    ans=5
flag=0
for j in data:
    if j < N:
        flag=1
if flag==1:
    print(ans+1)
else:
    ans=5
    print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = []
s = 0
l = int(input())

for i in range(5):
    n.append(int(input()))

n = np.array(n)
for idx in range(len(n)-1):
    if l % n[idx] == 0:
        k = int(np.floor(l/n[idx]))
    else:
        k = int(np.floor(l/n[idx])+1)
    s += k
#    print(str(idx)+':'+str(l)+';'+str(s))
    if n[idx]/n[idx+1] <= 1:
        if l % n[idx] != 0:
            l = l % n[idx]
        else:
            l = n[idx]
    else:
        l -=n[idx+1]*(k-1)
if l % n[4] == 0:
    s += int(np.floor(l/n[4]))
else:
    s += int(np.floor(l/n[4])+1)
print(s)

Submission status: Wrong Answer

Solution code:
import sys
import math

def main(inp):
    N=int(next(inp).split()[0])
    cap = [int(next(inp).split()[0]) for _ in range(5)]
    
    time=math.ceil(N/cap[0])
    
    for i in range(1,5):
        if(cap[i-1]<=cap[i]):
            cap[i]=cap[i-1]
            time+=1
        elif(cap[i-1]>=N):
            time+=math.ceil(N/cap[i])
        else: time+=math.ceil(N/cap[i])-1
            
    return time
  
print(main(sys.stdin))

Submission status: Wrong Answer

Solution code:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
f=int(input())

print(a // min(b,c,d,e,f) + 1 + 4)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())     
     
   
'''
各都市ごとに下記の４つを求める。

最初に到達した時間・人数
最後に到達した時間・人数
'''

import math

# 1st
first_cnt_1st = A
if N % A == 0:
  last_cnt_1st = A
else:
  last_cnt_1st = N % A

# 2nd
first_min_2nd = 1
first_cnt_2nd = A
last_min_2nd = math.ceil((N /A))
last_cnt_2nd = last_cnt_1st

# 3rd
first_min_3rd = 2
first_cnt_3rd = min(A,B)
last_min_3rd = last_min_2nd + math.ceil(last_cnt_2nd / B)
if last_cnt_2nd % B == 0:
  last_cnt_3rd = B
else:
  last_cnt_3rd = last_cnt_2nd % B

# 4th
first_min_4th = 3
first_cnt_4th = min(first_cnt_3rd,C)
last_min_4th = last_min_3rd + math.ceil(last_cnt_3rd / C)
if last_cnt_3rd % C == 0:
  last_cnt_4th = C
else:
  last_cnt_4th = last_cnt_3rd % C

# 5th
first_min_5th = 4
first_cnt_5th = min(first_cnt_4th,D)
last_min_5th = last_min_4th + math.ceil(last_cnt_4th / D)
if last_cnt_4th % D == 0:
  last_cnt_5th = D
else:
  last_cnt_5th = last_cnt_4th % D

# 6th
first_min_6th = 5
first_cnt_6th = min(first_cnt_5th,E)
last_min_6th = last_min_5th + math.ceil(last_cnt_5th / E)
if last_cnt_5th % E == 0:
  last_cnt_6th = E
else:
  last_cnt_6th = last_cnt_5th % E


print(last_min_6th)

Submission status: Wrong Answer

Solution code:
a=[0,0,0,0,0]
n=[0,0,0,0,0]
N=int(input())
a[0]=int(input())
a[1]=int(input())
a[2]=int(input())
a[3]=int(input())
a[4]=int(input())
if(N==0):
  print(0)
  exit()
for i in range(5):
  n[i]=-(-N // a[i])
time=n[0]  
for i in range(4):
  if n[i]>n[i+1]:
    time+=1
  else:
    time+=n[i+1]-n[i]+1
print(time)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

time = 0
cnt = 1
for prev, after in [(A, B), (B, C), (C, D), (D, E), (E, 0)]:
  if prev < N:
    t = N // prev + int(N % prev > 0)
    if prev <= after:
      time += t
      if N % prev:
        N = N % prev
      else:
        N = prev
    else:
      time += t
      if N % prev:
        N = (prev - after) * (time - cnt) + N % prev
      else:
        N = (prev - after) * (time - cnt) + prev
  else:
    time += 1
  cnt += 1
print(time)

Submission status: Wrong Answer

Solution code:
N = int(input())
numbers = [int(input()) for _ in range(5)]
flag = True

for number in numbers:
    if number < N:
        flag = False
        
if flag:
    print(5)

else:
    sum_number = 0
    tunnel = 0
    flag = True
    
    for i in range(len(numbers)-1):
        sum_number += numbers[i]

        if numbers[i+1] < numbers[i]:
            tunnel += 1
        
        if N <= sum_number:
            print(5 + tunnel + N // numbers[0])
            flag = False
            break
            
    if flag:
        print(5 + tunnel + N // numbers[0])

Submission status: Wrong Answer

Solution code:
import math
n,a,b,c,d,e=[int(input()) for _ in range(6)]
num=[a,b,c,d,e]
ans=0
ab=0
for i in range(1,len(num)):
    ab+=num[i]-num[i-1]
ans+=math.ceil(n/a)
ans+=math.ceil(a/b)
ans+=math.ceil((a/b)/c)
ans+=math.ceil(((a/b)/c)/d)
ans+=math.ceil((((a/b)/c)/d)/e)
if ab<0:
    ans=math.ceil(n/min(num))+abs(ab)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import os
import math

n = int(input())
people = []
for i in range(5):
    people.append(int(input()))
groupnum = n//min(people) + 1
print(groupnum + 4)

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
List=[int(input()) for i in range(5)]
sList = sorted(List, reverse=True)
if sList[4]>=N:
  print(5)
else:
  print(math.ceil(N/sList[4])+5)

Submission status: Wrong Answer

Solution code:
N = int(input())
moves = [int(input()) for _ in range(5)]
a = min(moves)
lst = [N % a ,0,0,0,0]
ret = N // a


def hoge(lst):
    l1 = [max(x -y , 0) for x, y in zip(lst, moves)]
    l2 = [min(x ,y) for x, y in zip(lst, moves)]
    l1.append(0)
    l2.insert(0,0)
    tmp = [ a + b for a, b in zip(l1, l2)]
    return tmp[0:5]

while sum(lst) > 0:
    lst = hoge(lst)
    ret += 1

print(ret)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

array = [a,b,c,d,e]

m = min(array)
if n <= m: print(5)
else: 
	if n%m == 0:
		print(5 + (n//m))
	else:
		print(4 + (((n//m)+1)*m)//m)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

if min(n,a,b,c,d,e)==n:
  print(5)
  
elif min(n,a,b,c,d,e)==a:
  t=0
  t+=(n//a)+1
  t+=4
  print(t)
  
elif min(n,a,b,c,d,e)==b:
  t=0
  t+=1
  t+=(n//b)+1
  t+=3
  print(t)
  
elif min(n,a,b,c,d,e)==c:
  t=0
  t+=2
  t+=(n//c)+1
  t+=2
  print(t)  
  
elif min(n,a,b,c,d,e)==d:
  t=0
  t+=3
  t+=(n//d)+1
  t+=1
  print(t)  
  
elif min(n,a,b,c,d,e)==e:
  t=0
  t+=4
  t+=(n//e)+1
  print(t)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
S = [0,0,0,0,0]
S[0] = int(input())
S[1] = int(input())
S[2] = int(input())
S[3] = int(input())
S[4] = int(input())

ct = 5
MIN = S[0]
f = 0

if N <= S[0] :
    f = 0
else :
    ct = ct + (N // S[0])
    f = 1

for i in range(4):
    if f == 0 and N <= S[i+1] :
        continue
    elif S[i+1] >= MIN:
        f = 1
        continue
    else:
        ct = ct + (MIN // S[i+1])
        MIN = S[i+1]
        f = 1
        
print(ct)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
A = []

A.append(int(input()))
A.append(int(input()))
A.append(int(input()))
A.append(int(input()))
A.append(int(input()))


neck = A.index(min(A))
ans = (math.ceil(n/min(A))+4-neck)

del A[:neck+1]

while len(A) > neck :
    neck = A.index(min(A))
    ans += (math.ceil(n / min(A)) + len(A) - neck)




print(ans+1)

Submission status: Wrong Answer

Solution code:
from sys import stdin

N = int(stdin.readline().rstrip())
max_ride = [int(stdin.readline().rstrip()) for _ in range(5)]

add_cnt = 0

for i in range(4):
    if max_ride[i+1] >= N:
        continue
    tmp = max_ride[i] - max_ride[i+1]
    add_cnt += tmp
    if add_cnt < 0:
        add_cnt = 0

res_time = 5 + N // min(max_ride) + add_cnt

print(res_time)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
num_list = [int(input()) for i in range(5)]

min_num = 0
group_num = 1
member_num = n

for num in num_list:
    if member_num > num:
        split_num = math.ceil(member_num / num)
        count = 0
        if min_num < num:
            split_num -= 1
            count += 1
        group_num = group_num * split_num + count
        min_num = member_num % num
        member_num = num

if group_num == 1:
    group_num -= 1
print(group_num + 5)

Submission status: Wrong Answer

Solution code:
n = int(input())
li = []
for i in range(5):
  li.append(int(input()))
c = n//li[0]
d = li[0]
e = n%li[0]
for i in range(1,5):
  if li[i] < d:
    c = (e+(d*c)%li[i])//li[i] + (d*c)//li[i]
    d = li[i]
    e = n%li[i]
print(c+5)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

sum_time = 0

def calc_time(n, x):
    if n % x == 0:
        res = n // x
    else:
        res = n // x + 1
    return res

sum_time += calc_time(n, a)
if sum_time >= calc_time(n, b):
    sum_time += 1
else:
    sum_time += calc_time(n, b) - 1
if sum_time >= calc_time(n, c):
    sum_time += 1
else:
    sum_time += calc_time(n, c) - 2
if sum_time >= calc_time(n, d):
    sum_time += 1
else:
    sum_time += calc_time(n, d) - 3
if sum_time >= calc_time(n, e):
    sum_time += 1
else:
    sum_time += calc_time(n, e) - 4
print(sum_time)

Submission status: Wrong Answer

Solution code:
N = int(input())
time = []
for i in range(5):
    time.append(int(input()))
#capacity = []

#mincap = time[0]
#minindex = 0
#for t,s in enumerate(time):
#    if s < mincap:
#        mincap = s
#        minindex = t
print((N // min(time) + 1) - 1 + 5)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

if min(n,a,b,c,d,e)==n:
  print(5)
  
elif min(n,a,b,c,d,e)==a:
  t=0
  t+=(n//a)+1
  t+=4
  print(t)
  
elif min(n,a,b,c,d,e)==b:
  t=0
  t+=1
  t+=(n//b)+1
  t+=3
  print(t)
  
elif min(n,a,b,c,d,e)==d:
  t=0
  t+=3
  t+=(n//d)+1
  t+=1
  print(t)  
  
elif min(n,a,b,c,d,e)==e:
  t=0
  t+=4
  t+=(n//e)+1
  print(t)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

time = 0
cnt = 1
for prev, after in [(A, B), (B, C), (C, D), (D, E), (E, 0)]:
  if prev < N:
    t = N // prev + int(N % prev > 0)
    if prev <= after:
      time += t
      N = prev
    else:
      time += t
      if N % prev:
        N = (prev - after) * (time - cnt) + N % prev
      else:
        N = (prev - after) * (time - cnt) + prev
  else:
    time += 1
  cnt += 1
print(time)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
ListN=[A,B,C,D,E]
ListN.sort()
q=ListN[0]
w=(N//q)+1 #律速段階の輸送回数
print(w+4)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
X=[a,b,c,d,e]

if n%a==0:
    cnt=n//a+4
else:
    cnt=n//a+5 
    
I=[]    
res=X[0]
for j in range(4):
    if res>X[j+1]:
        res=X[j+1]
        I.append(j)




for i in I:
    if n%X[i]==0:
        p=n//X[i]
    else:
        p=n//X[i]+1
    
    if n%X[i+1]==0:
        q=n//X[i+1]
    else:
        q=n//X[i+1]+1
    
    
        
    if X[i]<=X[i+1]:
        continue
    else:
        cnt+=q-p
        

print(cnt)

Submission status: Wrong Answer

Solution code:
N=int(input()) 
A=int(input()) 
B=int(input()) 
C=int(input()) 
D=int(input()) 
E=int(input())

x = [A,B,C,D,E] 
pace = min(x) 
y = int(N/pace)+1
print(y+4)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

l = [A, B, C, D, E]
minCapa = A
min = 0
count = 0
for i in range(5):
    if minCapa >= l[i]:
        minCapa = l[i]
        min = i

for i in range(min + 1):
    if int(N / l[i]) + 1 - i < 0:
        count += 1
    else:
        count += int(N / l[i]) + 1 - i

print(count + 4 - min)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

f=[a,b,c,d,e]
g=[0,0,0,0,0,n]
ans=0

print(n//min(f)+5)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

cs = [a,b,c,d,e]

min_idx = cs.index(min(cs))

if min_idx == 0:
    t = int(n / cs[min_idx]) + 1
elif min_idx == 1:
    amari = n % cs[min_idx-1]
    t = int(cs[min_idx-1] / (cs[min_idx-1] - cs[min_idx])) + 1
    if amari != 0:
        t = t - 1
else:
    amari = cs[min_idx-2] % cs[min_idx-1]
    t = int(cs[min_idx-1] / (cs[min_idx-1] - cs[min_idx])) + 1
    if amari != 0:
        t = t - 1

print(4 + t)