#C4554. Maximum Satisfied Borrower Requests
Maximum Satisfied Borrower Requests
Maximum Satisfied Borrower Requests
You are given a library containing \( m \) different books. Each book is uniquely identified by a string and has a certain number of available copies. There are \( n \) borrowers, each of whom makes a request by listing the books they wish to borrow. A request is fully satisfied if every book listed in the request can be provided from the current inventory.
When a request is satisfied, the number of available copies for each requested book is decreased accordingly. The order in which requests are fulfilled can affect the total number of satisfied requests. Your task is to determine the maximum number of borrower requests that can be completely fulfilled.
Input: The first part of the input contains the number of books and their available copies. The following sections describe the borrowers and their respective requests.
Note: Some formulas are presented in \( \LaTeX \) format, e.g., \( m \) and \( n \).
inputFormat
The input is given through standard input (stdin) and has the following format:
\( m \) book_id1 copies1 book_id2 copies2 ... (total \( m \) lines) \( n \) \( k_1 \) book_id book_id ... (\( k_1 \) values) \( k_2 \) book_id book_id ... (\( k_2 \) values) ... (total \( n \) requests)
For example:
3 book1 2 book2 1 book3 5 4 2 book1 book2 3 book1 book3 book2 1 book3 2 book1 book3
outputFormat
Output a single integer to standard output (stdout) representing the maximum number of borrower requests that can be fully satisfied.
## sample3
book1 2
book2 1
book3 5
4
2 book1 book2
3 book1 book3 book2
1 book3
2 book1 book3
3