Advertisement
viligen

robotics

Jan 15th, 2022
944
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.14 KB | None | 0 0
  1. from collections import deque
  2.  
  3. products = deque()
  4.  
  5. robots_list = []
  6.  
  7. robots_data = input().split(";")
  8. hours, minutes, seconds = [int(s) for s in input().split(":")]
  9. start_time_seconds = hours * 3600 + minutes * 60 + seconds
  10. for robot in robots_data:
  11.     robot_name, process_time = robot.split("-")
  12.     busy_until_time = 0
  13.     robots_list.append({'name': robot_name, 'data': [int(process_time), busy_until_time]})
  14.  
  15. while True:
  16.     product = input()
  17.     if product == "End":
  18.         break
  19.     products.append(product)
  20.  
  21. while products:
  22.     current_product = products.popleft()
  23.     is_taken = False
  24.     start_time_seconds += 1
  25.     for robot in robots_list:
  26.         if robot['data'][1] <= start_time_seconds:
  27.             robot['data'][1] = start_time_seconds + robot['data'][0]
  28.             h = start_time_seconds // 3600
  29.             m = (start_time_seconds % 3600) // 60
  30.             s = (start_time_seconds % 3600) % 60
  31.             h %= 24
  32.             print(f"{robot['name']} - {current_product} [{h:02d}:{m:02d}:{s:02d}]")
  33.             is_taken = True
  34.             break
  35.     if not is_taken:
  36.         products.append(current_product)
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement