← 返回 xai 的题目列表Minimum Time to Produce a Goal Dataset in a Data Pipeline (Parallel Tasks)
类型:online_judge
Problem: Minimum Time to Produce a Goal Dataset in a Parallel Data Pipeline
You are given a set of data processing tasks that form a data pipeline. Each task:
Consumes one or more input datasets
Produces a single output dataset
Takes a fixed amount of time to execute
Rules:
A task can start only after all its input datasets are available.
Multiple tasks can run in parallel (unlimited parallelism).
Any dataset that is not produced by any task is considered available at time 0 (a source dataset).
Given goal_dataset, compute the minimum time required to produce it.
Input
tasks: a list of tasks, each defined as:
([input_datasets], output_dataset, time_cost)
goal_dataset: a string dataset id
Output
Return an integer: the minimum time to produce goal_dataset.
Example
tasks = [
(["d0", "d1", "d2"], "d3", 30),
(["d1", "d2"], "d4", 15),
(["d2", "d3"], "d5", 100),
(["d0", "d3", "d4"], "d6", 60)
]
goal_dataset = "d6"
Expected output:
90
Constraints (assume for interview)
1 <= len(tasks) <= 2e5
Total number of input edges <= 2e5
time_cost is a positive integer
Dataset ids are strings
Assume each output dataset is produced by at most one task; if cycles exist, you may define behavior (e.g., unreachable/error).
Example
Input
4
d0 d1 d2 -> d3 30
d1 d2 -> d4 15
d2 d3 -> d5 100
d0 d3 d4 -> d6 60
d6
Output
90