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:
import sys
# import bisect
# import math
# import itertools
# import numpy as np
# import collections

"""Template"""


class IP:
    """
    入力を取得するクラス
    """

    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        # 参考
        # https://blog.rossywhite.com/2018/08/06/bit-search/
        # https://atcoder.jp/contests/abc105/submissions/4088632
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    # output.append(a[j])
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def S(self, s, r=0, m=-1):
        """
        ソート関係行います。色々な設定あります。
        :param s: 元となるリスト
        :param r: reversするかどうか 0=False 1=True
        :param m: （2次元配列）何番目のインデックスのソートなのか
        :return: None
        """
        r = bool(r)
        if m == -1:
            s.sort(reverse=r)
        else:
            s.sort(reverse=r, key=lambda x: x[m])

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x // y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)

    def gcd(self, x, y):
        if y == 0:
            return x
        else:
            return self.gcd(y, x % y)


"""ここからメインコード"""


def main():
    # 1文字に省略
    r, e, p = range, enumerate, print
    ip = IP()
    id = Idea()
    mod = 10 ** 9 + 7

    """この下から書いてね"""
    n = ip.I()
    li = ip.ILS(5)
    k = min(li)
    p(n // k + 5)


main()

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[int(input()) for i in range(5)]
m=min(A)
print(int((N-(N%m))/m+5))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(5 + N // min(V))

Submission status: Wrong Answer

Solution code:
a = []
N = int(input())
min_v = 10**15 + 1
for i in range(5):
    v = int(input())
    min_v = min(min_v, v)

print(N//min_v + 5)

Submission status: Wrong Answer

Solution code:
N = int(input())
duration = [int(input()) for _ in range(5)]
if(min(duration)>=N):
    print(5)
else:
    print(int(N/min(duration))+5)

Submission status: Wrong Answer

Solution code:
n = int(input())
mins = [int(input()) for _ in range(5)]
ans = n // min(mins) + (1 * (n%min(mins)>0))
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = []
su = 0
for i in range(5):
    k = int(input())
    a.append([k,-(-1*n//k)])

for i in range(5):
    if i == 0:
        su += a[i][1]
    else:
        if a[i-1][1] < a[i][1]:
            su += a[i][1]-1
        else:
            su += 1
print(su%(10**9+7))

Submission status: Wrong Answer

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

s = [a, b, c, d, e]
mins = min(s)
ans = math.floor(n*1.0/mins) + len(s)

print(ans)

Submission status: Wrong Answer

Solution code:
def solve():
  N = int(input())
  ABCDE = [int(input()) for i in range(5)]
  return 5 + (N // min(ABCDE))

print(solve())

Submission status: Wrong Answer

Solution code:
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

N=ri()
A=rr(5)
ma=min(A)

print(5+N//ma)

Submission status: Wrong Answer

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

print(N // min(A) + 5)

Submission status: Wrong Answer

Solution code:


import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return int(stdin.readline())

N = li()
a = li()
b = li()
c = li()
d = li()
e = li()

bottle_neck = min([a, b, c, d, e]) + 1
red = N // bottle_neck
print(5 + red)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
l = []

for _ in range(5):
  l.append(int(input()))
neck = min(l)

group_num = n / neck if n % neck == 0 else n // neck + 1

print(4+group_num)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(input()) for i in range(5)]
a.sort()
print((N//a[0]+1)+4)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
time_list = [int(input()) for _ in range(5)]

bottle_neck = np.argmin(time_list)
ans = 5
if bottle_neck<N:
    ans += N//time_list[bottle_neck]
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
clist = [int(input()) for _ in range(5)]
cmin = min(clist)
print(5 + n//cmin)

Submission status: Wrong Answer

Solution code:
a = 6*[0]
for i in range(6):
    a[i] = int(input())

min_n = min(a[1:])

print(5+a[0]//min_n)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

n = int(input())

nums = []
for _ in range(5):
    nums.append(int(input()))

minidx = 0
for i in range(5):
    if nums[i] < nums[minidx]:
        minidx = i

minnum = nums[minidx]

print(4 + n // minnum + 1)

Submission status: Wrong Answer

Solution code:
N = int(input())
trans = []
for i in range(5):
    trans.append(int(input()))
narrow = min(trans)
pair = N // narrow + 1
print(str(pair+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())

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

min_norimono = min(norimono_lis)

ans = (n//min_norimono)+1 + 4
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
ns = [int(input()) for _ in range(6)]
ans = 0
min_n = min(ns[1:])
ans = 5 + ns[0] // min_n
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
data = [int(input()) for _ in range(6)]
n = data[0]
ae = data[1:]
idx_band = np.argmin(ae)
band  = ae[idx_band]
print(n//band + 5 )

Submission status: Wrong Answer

Solution code:
board = []
for _ in range(6):
    board.append(int(input()))

n = board[0]
neck = min(board[1:])

if neck == 1:
    print(n + 4)
else:
    print(board[0] //  + 5)

Submission status: Wrong Answer

Solution code:
N = int(input())
t = [ int(input()) for _ in range(5) ]
a = min(t)

print(5+N//a)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    n = get_int()
    a = get_int()
    b = get_int()
    c = get_int()
    d = get_int()
    e = get_int()
    m = min(a, b, c, d, e)
    print(5 + n // m)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:


def main():
    N = int(input())
    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())

    m = min([a,b,c,d,e])  # bottle neck

    ans = (N//m) + (N%m==0) + 1
    ans += 4

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# encoding:utf-8
import copy
import numpy as np
import random
import bisect #bisect_left　これで二部探索の大小検索が行える

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

traffic_time.sort()

wait_time = n//traffic_time[0]
print(wait_time+5)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = ni()
b = ni()
c = ni()
d = ni()
e = ni()

k = min(a,b,c,d,e)

ans = 5 + n // k
print(ans)

Submission status: Wrong Answer

Solution code:
import math
import sys

N=int(input())
a=[int(input()) for i in range(5)]

m=min(a)

tmp=-1
for i in range(5):
    if a[i]==m: p=i

print(i)

print(math.ceil(N/m)+4)

Submission status: Wrong Answer

Solution code:

import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return int(stdin.readline())

N = li()
a = li()
b = li()
c = li()
d = li()
e = li()

bottle_neck = min([a, b, c, d, e])
red = N // bottle_neck
print(5 + red)

Submission status: Wrong Answer

Solution code:
n = int(input())
time = []

for _ in range(5):
    time.append(int(input()))

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

Submission status: Wrong Answer

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

print(5+N//min(li))

Submission status: Wrong Answer

Solution code:
N = int(input())
ABCDE = [int(input()) for i in range(5)]
key = min(ABCDE)
key = N / key + 4
if key != int(key):
    key = int(key + 1)
print(key)

Submission status: Wrong Answer

Solution code:
n = int(input())
atoe = [int(input()) for i in range(4)]

a = min(atoe)

if n%a==0:
    print(n//a+4)
else:
    print(n//a+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())


minimum=min(A,B,C,D,E)
print(N//minimum +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())

count = N // min(A,B,C,D,E)
print(count+5)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = []
su = 0
for i in range(5):
    k = int(input())
    a.append([k,-(-1*n//k)])

for i in range(5):
    if i == 0:
        su += a[i][1]
    else:
        if a[i-1][1] < a[i][1]:
            su += a[i][1]-1
        else:
            su += 1
print(su)

Submission status: Wrong Answer

Solution code:
N= int(input())
ts = [int(input()) for i in range(5)]
print(int(N/min(ts)) + 5)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import itertools
import sys
import math
from functools import lru_cache

# 1整数
# n = int(input())

# 空白区切り2変数
from queue import Queue
from operator import mul
from functools import reduce
from queue import Queue
from operator import mul
from functools import reduce
from functools import lru_cache

input = sys.stdin.readline

# N個整数
# a, b, c = list(map(int, input().split()))

# 1整数
# n = int(input())

# 空白区切りリスト整数
# b = list(map(int, input().split()))

# 空白区切り文字列
# t, d = input().split()

n = int(input())

mm = 9999999999999999

ll = []
for i in range(5):
    mm = min(mm, int(input()))
    # ll.append(int(input()))

print(n // mm + 5)

Submission status: Wrong Answer

Solution code:
board = []
for _ in range(6):
    board.append(int(input()))
print(board[0] // min(board[1:]) + 5)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import itertools
import collections
import functools
import math
from queue import Queue
# import numpy as np
INF = float("inf")


def solve(N: int, A: int, B: int, C: int, D: int, E: int):
    t = [A, B, C, D, E]
    mt, MT = min(t), max(t)
    print(5+N//mt)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    E = int(next(tokens))  # type: int
    solve(N, A, B, C, D, E)


if __name__ == '__main__':
    main()

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=min(A,B,C,D,E)
if x<N:
    print(N//x+5)
else:
    print(5)

Submission status: Wrong Answer

Solution code:
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g


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

mov.sort()

min = mov[0]

if min >= n:
    print(5)
else:
    ex = n // min
    print(5+ex)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, A: int, B: int, C: int, D: int, E: int):
    R = [A, B, C, D, E]
    mn = min(R)
    ret = max(5, 5 + (N + 1) // mn - 1)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    E = int(next(tokens))  # type: int
    solve(N, A, B, C, D, E)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[]
for i in range(5):
  l.append(int(input()))
t=min(l)
print((n//t)+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())

min_ = min(a,b,c,d,e)
count = 5 + (n//min_)

print(count)

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 = min(a,b,c,d,e)
print(5+n//x)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[int(input()) for _ in range(5)]
print(n//min(x)+5)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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=min(A,B,C,D,E)
loss=N//x

print(5+loss)

Submission status: Wrong Answer

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

M = min(A,B,C,D,E)
ans = N//M + 5
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = [int(input()) for i in range(5)]
print(5 + n//min(lis))

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python
import sys 
input = sys.stdin.readline

n = int(input())
a = [int(input()) for _ in range(5)]

ans = 0 
lst = [n, 0, 0, 0, 0, 0]
while lst[5] < n:
    for i in [5, 4, 3, 2, 1]: 
        if lst[i-1] >= a[i-1]:
            lst[i] += a[i-1]
            lst[i-1] -= a[i-1]
        else:
            lst[i] += lst[i-1]
            lst[i-1] = 0 
    ans += 1
    #print('lst =', lst)

print(ans)

Submission status: Time Limit Exceeded

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

arr = [N,0,0,0,0]
count = 0

while True:
    count += 1
    arr[4] =max(0,arr[4]-E)
    arr[4] +=min(D,arr[3])

    arr[3] =max(0,arr[3]-D)
    arr[3] +=min(C,arr[2])

    arr[2] =max(0,arr[2]-C)
    arr[2] +=min(B,arr[1])

    arr[1] =max(0,arr[1]-B)
    arr[1] +=min(A,arr[0])

    arr[0] =max(0,arr[0]-A)
    if sum(arr) == 0:
        break

print(count)

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    num = [int(input()) for _ in range(5)]

    bucket = [0] * 6
    bucket[0] = N
    ans = 0
    temp = [0] * 6
    temp[0] = N

    while True:
        for i in range(5):
            if bucket[i] > 0 and bucket[i] >= num[i]:
                temp[i] -= num[i]
                temp[i+1] += num[i]
            elif bucket[i] > 0 and bucket[i] < num[i]:
                temp[i] -= bucket[i]
                temp[i+1] += bucket[i]
            else:
                continue

        ans += 1
        for j in range(6):
            bucket[j] = temp[j]

        if bucket[5] == N:
            break

    return(ans)

print(main())

Submission status: Time Limit Exceeded

Solution code:
# input
N = int(input())

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

# check
total = 0
citys = [N] + ([0] * 5)

while citys[5] != N:
    for i in range(5, 0, -1):

        if 0 < citys[i - 1] <= Cap[i - 1]:
            mov = citys[i - 1]
            citys[i] += mov
            citys[i - 1] = 0
        elif citys[i - 1] > Cap[i - 1]:
            mov = Cap[i - 1]
            citys[i] += mov
            citys[i - 1] -= mov
        else:
            pass
    total += 1

print(total)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
A = [int(input()) for _ in range(5)] + [0]
B = [n] + [0]*5
cnt = 0

while not B[5] == n:

    cnt+=1
    for i in range(5,0,-1):
        B[i] =B[i] - min(B[i],A[i]) + min(B[i-1],A[i-1])
    B[0] = B[0] - min(B[0],A[0])

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A = [int(input()) for _ in[0]*5]
A.reverse()
d=[0]*6
d[5]=N
i=0
while d[0] < N:
  i+=1
  for j in range(5):
    v=min(d[j+1],A[j])
    d[j] += v
    d[j+1] -= v
print(i)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
ABCDE=[]
for i in range(5):
  ABCDE.append(int(input()))
people=[0]*6
people[0]=N

#地点iから人が移動する関数
def move_people(ABCDE,people,people_move,i):
  if people[i]>0:
    move=min(ABCDE[i],people[i])#最大人数と在籍人数の小さいほうだけ移動
    people_move[i]+=move
  else:
    pass

#貪欲法
count=0
while(people[-1]!=N):
  people_move=[0]*5#乗船人数は毎回更新
  for i in range(5):
    move_people(ABCDE,people,people_move,i)
  for i in range(5):
    people[i+1]+=people_move[i]
    people[i]-=people_move[i]
  count+=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = [0] * 5
for i in range(5):
    x[i] = int(input())
# m = np.zeros(6, dtype=int)
m = [0] * 6
m[0] = n
time = 0
while m[5] != n:
    #for i in range(100):
    if m[5] == n:
        break
    time += 1
    for i in reversed(range(1, 6)):
        transpose = max(min(x[i-1], m[i-1]), 0)
        m[i-1] -= transpose
        m[i] += transpose
    # print(f"m = {m}")
print(time)

Submission status: Time Limit Exceeded

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

dp = [N,0,0,0,0,0]
ans = 0
while dp[-1]<N:
    for i in range(4,-1,-1):
        if dp[i]>0:
            if dp[i]>=T[i]:
                dp[i] -= T[i]
                dp[i+1] += T[i]
            else:
                dp[i+1] += dp[i]
                dp[i] = 0
    ans +=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
P = [int(input()) for _ in range(6)]
N,A,B,C,D,E = P[0],P[1],P[2],P[3],P[4],P[5]
N1,N2,N3,N4,N5,goal = P[0],0,0,0,0,0
ans = 0

while goal < N:
  if N5 > 0:
    goal += min(E,N5)
    N5 -= min(E,N5)
    
  if N4 > 0:
    N5 += min(D,N4)
    N4 -= min(D,N4)
    
  if N3 > 0:
    N4 += min(C,N3)
    N3 -= min(C,N3)
    
  if N2 > 0:
    N3 += min(B,N2)
    N2 -= min(B,N2)
    
  if N1 > 0:
    N2 += min(A,N1)
    N1 -= min(A,N1)

  ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [int(input()) for _ in range(5)]
ch = [0]*6
ch[0] = n
cnt = 0
while ch[5]!=n:
    ch2 = [0]*5
    for i in range(5):
        ch2[i] = min(ch[i],a[i])
    for i in range(5):
        ch[i] -= ch2[i]
        ch[i+1] += ch2[i]
    cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ninzu = [int(input()) for i in range(5)]
cond = [N, 0, 0, 0, 0, 0]
flag = [0] * 6
cnt = 0
while cond[5] < N:
    if cond[0] >= ninzu[0]:
        flag[0] = 1
    else:
        flag[0] = 0
    if cond[1] >= ninzu[1]:
        flag[1] = 1
    else:
        flag[1] = 0
    if cond[2] >= ninzu[2]:
        flag[2] = 1
    else:
        flag[2] = 0
    if cond[3] >= ninzu[3]:
        flag[3] = 1
    else:
        flag[3] = 0
    if cond[4] >= ninzu[4]:
        flag[4] = 1
    else:
        flag[4] = 0
    for i in range(4, -1, -1):
        if flag[i]:
            cond[i + 1] += ninzu[i]
            cond[i] -= ninzu[i]
        else:
            cond[i + 1] += cond[i]
            cond[i] = 0
    cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

city = [N,0,0,0,0,0]
time = 0

while city[5] < N:
  
  # print(city)
  for i in reversed(range(0, 5)):
    if city[i] != 0:
      if city[i] < ABCDE[i]:
        city[i+1] += city[i]
        city[i] = 0 
      else :
        city[i+1] += ABCDE[i]
        city[i] -= ABCDE[i]



  time += 1
  

print(time)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
#print(N,A,B,C,D,E)

def transport(situ):
    temp=[0]*6
    temp[0]+=situ[0]-min(A, situ[0])
    temp[1]+=min(A, situ[0])

    temp[1]+=situ[1]-min(B, situ[1])
    temp[2]+=min(B, situ[1])

    temp[2] += situ[2] - min(C, situ[2])
    temp[3] += min(C, situ[2])

    temp[3] += situ[3] - min(D, situ[3])
    temp[4] += min(D, situ[3])

    temp[4] += situ[4] - min(E, situ[4])
    temp[5] += min(E, situ[4])

    temp[5]+=situ[5]

    return temp

popu=[N, 0, 0, 0, 0, 0]
time=0
while popu!=[0, 0, 0, 0, 0, N]:
    popu=transport(popu)
    time+=1

print(time)

Submission status: Time Limit Exceeded

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

p1, p2, p3, p4, p5, p6 = n, 0, 0, 0, 0, 0
ans = 0

def carry(p1, p2, num):
    if p1>=num:
        p1 -= num
        p2 += num
    elif 0<p1<num:
        p2 += p1
        p1 = 0
    return p1, p2

while p6!=n:
    ans += 1
    p5, p6 = carry(p5, p6, e)
    p4, p5 = carry(p4, p5, d)
    p3, p4 = carry(p3, p4, c)
    p2, p3 = carry(p2, p3, b)
    p1, p2 = carry(p1, p2, a)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
list_L = [int(input()) for _ in range(5)]
list_H = [n, 0, 0, 0, 0, 0]
ans = 1
while True:
    if list_H[5] == n:
        break
    for i in range(4, -1, -1):
        if list_H[i] >= list_L[i]:
            list_H[i+1] += list_L[i]
            list_H[i] -= list_L[i]
        else:
            list_H[i+1] += list_H[i]
            list_H[i] -= list_H[i]
    ans += 1

print(ans-1)

Submission status: Time Limit Exceeded

Solution code:

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

town =[0 for _ in range(6)] 
town[0] = n

t = 0
while town[-1] != n:
	t += 1
	for i in reversed(range(5)):

		temp = min(town[i],trans[i])
		town[i] -= temp
		town[i+1] += temp
print(t)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
r = [0,0,0,0,0]
for i in range(0,5):
    r[i] = int(input())
place = [n,0,0,0,0,0]
time = 0
while(place[-1] != n):
    for i in range(5,0,-1):
        if(place[i-1] < r[i-1]):
            place[i] += place[i-1]
            place[i-1] = 0
        else:
            place[i] += r[i-1]
            place[i-1] -= r[i-1]
    time += 1
print(time)

Submission status: Time Limit Exceeded

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

status = [0 for i in range(6)]
status[0] = n
status.reverse()

# print(mov)
# print(status)

count = 0
while True:
    count += 1
    for i in range(1,len(status)):
        status[i-1] += min(status[i],mov[i-1])
        status[i] -= min(status[i],mov[i-1])
    if status[0]==n:
        print(count)
        exit()
    elif status[-1]==0:
        status.pop(-1)
        mov.pop(-1)

Submission status: Time Limit Exceeded

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

status = [0 for i in range(6)]
status[0] = n
status.reverse()

# print(mov)
# print(status)

count = 0
while True:
    count += 1
    for i in range(1,6):
        status[i-1] += min(status[i],mov[i-1])
        status[i] -= min(status[i],mov[i-1])
    if status[0]==n:
        print(count)
        exit()

Submission status: Time Limit Exceeded

Solution code:
n,a,b,c,d,e=[int(input()) for _ in range(6)]
cnt=[n,0,0,0,0,0]
t=0
while cnt[5]!=n:
    c0,c1,c2,c3,c4,c5=cnt[0],cnt[1],cnt[2],cnt[3],cnt[4],cnt[5]
    cnt[0]-=min(a,c0)
    cnt[1]+=min(a,c0)-min(b,c1)
    cnt[2]+=min(b,c1)-min(c,c2)
    cnt[3]+=min(c,c2)-min(d,c3)
    cnt[4]+=min(d,c3)-min(e,c4)
    cnt[5]+=min(e,c4)
    t+=1
print(t)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
move_lst = [int(input()) for _ in range(5)]
time = 0
people_lst = [n] + [0]*5

while people_lst[-1]!=n:
    time += 1

    for i in range(4,-1,-1):
        people = people_lst[i]
        move = move_lst[i]

        people_lst[i] -= min(people, move)
        people_lst[i+1] += min(people, move)

print(time)