Project profit maximization

Write codeHard40 min

Your task

You can launch any subset of projects. Project i yields profit projects[i] (a non-negative integer). Each entry [p, m] in requires means project p can only run if machine m is purchased; machine m costs machines[m] (non-negative). A machine, once bought, may be shared by any number of projects. Choose the subset of projects that maximizes total profit minus total machine cost. Return that maximum net value (it is never negative since launching nothing yields 0). Constraints: up to 60 projects, up to 60 machines.

Examples

max_project_profit(projects: list[int], machines: list[int], requires: list[list[int]]) -> int
Example 1
Inputmax_project_profit([10, 10], [5], [[0, 0], [1, 0]])
Output15