You are given n keys and m locks. For each key keyi, you can use it to open certain
locks and you can use the key no more than ni times. Now you know which key can open which
lock(s) and value of all ni, please design an ecient algorithm to compute the maximum number
of locks you can open. Show all of your work.
For example: you have 2 keys and 3 locks, n1 = 1; n2 = 2. key1 can open lock1 and key2 can
open all three locks. The optimal solution could be like this: key1 opens lock1 and key2 opens the
rest two locks. (Noting that if you use key2 to open lock1, you can only open at most two locks)