Company: INFOSYS
Difficulty: medium
You have N tasks and P phases . Task i assigned to phase p contributes value v[i][p] and takes duration d[i][p] . Each phase runs sequentially ; within a phase, tasks run in parallel . The duration of a phase equals the maximum task duration in that phase. Each task must be assigned to exactly one phase . The total project duration is the sum of phase durations . Maximize total value subject to total project duration ≤ T . Find the maximum total value ; -1 if no valid assignment exists. Input Format The first line contains a integer, n, denoting the number of tasks. The second line contains a integer, p, denoting the number of phases. The third line contains a integer, t, denoting the maximum allowed total project duration. Each of the n lines contains p space-separated integers, representing row i of v. Each of the n lines contains p space-separated integers, representing row i of d. Constraints 1 ≤ n ≤ 8 1 ≤ p ≤ 4 1 ≤ t ≤ 10 2 1 ≤ v[i][j] ≤ 20 1 ≤ d[i][j