Tap here to switch tabs
Problem
Submissions

Problem: Finish Time of Tasks I

Try to solve the Finish Time of Tasks I problem.

Statement

You are given a tree with n tasks labeled from 00 to n−1n - 1, rooted at node 00. The tree structure is given by a 2extD2 ext{D} integer array edges of length n−1n - 1, where edges[i] =[ui,vi]= [u_i, v_i] denotes an undirected edge between task uiu_i and task viv_i.

You are also given an integer array baseTime of length n, where baseTime[i] represents the base execution time of task i.

The tasks are executed according to the following rules:

  • If a task is a leaf node (it has no children), its finish time is equal to baseTime[i].

  • If a task has children, let earliest and latest be the minimum and maximum finish times among all its direct children, respectively.

    • The duration of the task itself is calculated as:

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Finish Time of Tasks I

Try to solve the Finish Time of Tasks I problem.

Statement

You are given a tree with n tasks labeled from 00 to n−1n - 1, rooted at node 00. The tree structure is given by a 2extD2 ext{D} integer array edges of length n−1n - 1, where edges[i] =[ui,vi]= [u_i, v_i] denotes an undirected edge between task uiu_i and task viv_i.

You are also given an integer array baseTime of length n, where baseTime[i] represents the base execution time of task i.

The tasks are executed according to the following rules:

  • If a task is a leaf node (it has no children), its finish time is equal to baseTime[i].

  • If a task has children, let earliest and latest be the minimum and maximum finish times among all its direct children, respectively.

    • The duration of the task itself is calculated as: