Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
from itertools import permutations 
from time import sleep


def solve(nums):
    num_person, *caps = nums
    caps = caps + [0]
    #  (人数, 乗り物のキャパシティ) のタプルの配列
    cities = list(zip([num_person] + ([0] * (len(caps) - 1)), caps))
    time = 0

    # 最後の都市に全員が移動したら終了
    while cities[-1][0] < num_person:
        mov_nums = [min(*city) for i, city in enumerate(cities) if i < len(cities) - 1]
        for i, mov_num in enumerate(mov_nums):
            city = cities[i]
            next_city = cities[i + 1]
            cities[i] = (city[0] - mov_num, city[1])
            cities[i + 1] = (next_city[0] + mov_num, next_city[1])
        time = time + 1
    return time


def main():
    nums = [int(l) for l in stdin.readlines()]
    ans = solve(nums)
    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
from sys import stdin
from math import ceil

#  def solve(nums):
    #  num_person, *caps = nums
    #  caps = caps + [0]
    #  #  (人数, 乗り物のキャパシティ) のタプルの配列
    #  cities = list(zip([num_person] + ([0] * (len(caps) - 1)), caps))
    #  time = 0

    #  # 最後の都市に全員が移動したら終了
    #  while cities[-1][0] < num_person:
        #  print('|'.join([str(n) for n, cap in cities[:-1]]))
        #  mov_nums = [min(*city) for city in cities[:-1]]
        #  for i, mov_num in enumerate(mov_nums):
            #  city = cities[i]
            #  next_city = cities[i + 1]
            #  cities[i] = (city[0] - mov_num, city[1])
            #  cities[i + 1] = (next_city[0] + mov_num, next_city[1])
        #  time = time + 1
    #  return time


def solve(nums):
    num_person, *caps = nums
    return 4 + ceil(num_person / min(*caps))


def main():
    nums = [int(l) for l in stdin.readlines()]
    ans = solve(nums)
    print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
from itertools import permutations 
from time import sleep


def solve(nums):
    num_person, *caps = nums
    caps = caps + [0]
    #  (人数, 乗り物のキャパシティ) のタプルの配列
    cities = list(zip([num_person] + ([0] * (len(caps) - 1)), caps))
    time = 0

    # 最後の都市に全員が移動したら終了
    while cities[-1][0] < num_person:
        mov_nums = [min(*city) for city in cities[:-1]]
        for i, mov_num in enumerate(mov_nums):
            city = cities[i]
            next_city = cities[i + 1]
            cities[i] = (city[0] - mov_num, city[1])
            cities[i + 1] = (next_city[0] + mov_num, next_city[1])
        time = time + 1
    return time


def main():
    nums = [int(l) for l in stdin.readlines()]
    ans = solve(nums)
    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
from sys import stdin
from math import ceil

#  def solve(nums):
    #  num_person, *caps = nums
    #  caps = caps + [0]
    #  #  (人数, 乗り物のキャパシティ) のタプルの配列
    #  cities = list(zip([num_person] + ([0] * (len(caps) - 1)), caps))
    #  time = 0

    #  # 最後の都市に全員が移動したら終了
    #  while cities[-1][0] < num_person:
        #  print('|'.join([str(n) for n, cap in cities[:-1]]))
        #  mov_nums = [min(*city) for city in cities[:-1]]
        #  for i, mov_num in enumerate(mov_nums):
            #  city = cities[i]
            #  next_city = cities[i + 1]
            #  cities[i] = (city[0] - mov_num, city[1])
            #  cities[i + 1] = (next_city[0] + mov_num, next_city[1])
        #  time = time + 1
    #  return time


def solve(nums):
    num_person, *caps = nums
    return 4 + ceil(num_person / min(*caps))


def main():
    nums = [int(l) for l in stdin.readlines()]
    ans = solve(nums)
    print(ans)

if __name__ == '__main__':
    main()