← 返回 stripe 的题目列表Assigning Tasks to Workers Based on Skills and Task Types
类型:online_judge
Given a list of workers and tasks where each task has a duration, print out which worker is assigned to each task. Each worker has their own areas of expertise, and each task has a type. Tasks should be assigned to the fastest worker that handles the task type. Additionally, each task is linked to an account, and if an account's previous task was assigned to a worker, subsequent tasks from the same account should go to the same worker unless the task type is not supported by the worker.
Example
Input
workers = [{'id': 1, 'expertise': ['type1', 'type2']}, {'id': 2, 'expertise': ['type2', 'type3']}]
tasks = [{'id': 'task1', 'duration': 5, 'type': 'type1', 'account': 'A1'}, {'id': 'task2', 'duration': 3, 'type': 'type3', 'account': 'A2'}, {'id': 'task3', 'duration': 7, 'type': 'type2', 'account': 'A1'}]
Output
[(task1, 1), (task2, 2), (task3, 1)]