Advertisement
Kamend1

07. Robotics

Jan 10th, 2024
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. from collections import deque
  2.  
  3. robots = input().split(";")
  4. start_time = input().split(":")
  5. start_time_seconds = int(start_time[0]) * 3600 + int(start_time[1]) * 60 + int(start_time[2])
  6.  
  7. robots_queue = []
  8. for robot in robots:
  9.     robot = robot.split("-")
  10.     robot.append(start_time_seconds)
  11.     robots_queue.append(robot)
  12.  
  13. part = input()
  14. part_queue = deque()
  15. while part != "End":
  16.     part_queue.append(part)
  17.     part = input()
  18.  
  19. while len(part_queue) > 0:
  20.     part_taken = False
  21.     current_part = part_queue.popleft()
  22.     start_time_seconds += 1
  23.  
  24.     for current_robot in robots_queue:
  25.         if current_robot[2] <= start_time_seconds:
  26.             current_robot[2] = start_time_seconds + int(current_robot[1])
  27.             part_taken = True
  28.             time_taken = f"{start_time_seconds // 3600:02d}:{(start_time_seconds % 3600) // 60:02d}:{start_time_seconds % 60:02d}"
  29.             print(f"{current_robot[0]} - {current_part} [{time_taken}]")
  30.             break
  31.  
  32.     if not part_taken:
  33.         part_queue.append(current_part)
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement