Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import deque
- def next_second(h, m, s):
- s += 1
- if s >= 60:
- s = 0
- m += 1
- if m >= 60:
- m = 0
- h += 1
- if h >= 24:
- h = 0
- return [h, m, s]
- def are_any_robots_available(robots_waiting):
- for robot in sorted(robots_waiting):
- robot[1] -= 1
- if robot[1] == 0:
- robots.append([robot[0], robots_dict[robot[0]]])
- return list(filter(lambda x: x[1] > 0, robots_waiting))
- # robots = [x.split("-") for x in input().split(";")]
- robots = deque([[x[0], int(x[1])] for x in [x.split("-") for x in input().split(";")]])
- robots_dict = {x: y for (x, y) in robots}
- robots_unavailable = deque()
- time = list(map(int, input().split(":")))
- product = input()
- products = deque()
- while product != "End":
- products.append(product)
- product = input()
- while products:
- time = next_second(time[0], time[1], time[2])
- robots_unavailable = are_any_robots_available(robots_unavailable)
- current_product = products.popleft()
- if robots:
- current_robot = robots.popleft()
- print(f"{current_robot[0]} - {current_product} [{time[0]:02d}:{time[1]:02d}:{time[2]:02d}]")
- robots_unavailable.append(current_robot)
- else:
- products.append(current_product)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement