This question evaluates the ability to model and optimize resource allocation under capacity constraints, testing algorithmic skills in dynamic programming and combinatorial optimization for maximizing total fee.
You are given N transactions. Each transaction has:
id
(unique)
size
(positive integer)
fee
(non-negative integer)
A block has a maximum capacity B (total size). You must choose a subset of transactions to include in the block such that:
size
of chosen transactions is
<= B
fee
is
maximized
N
transactions:
[(id, size, fee), ...]
B
1 <= N <= 2000
1 <= B <= 100
1 <= size <= B
0 <= fee <= 10^9
Now each transaction may optionally have a parent_id. If a transaction is included, all its ancestors must also be included. Assume dependencies form a forest (no cycles).
B
that maximizes total fee.
Clarify what you would return if multiple optimal subsets exist (any is fine).