Implement maximum_item_counts(prices, queries).
prices[i] is the price of item i. Each query is [start, budget]: you may select any items whose zero-based indices are at least start, buying each eligible item at most once. The chosen indices need not be consecutive. Return the maximum number of items that can be bought without spending more than budget for each query, in query order.
Queries are independent; a purchase selected for one query does not remove an item from another. Equal prices at different indices still represent different items. For this interface, prices and budgets are nonnegative integers in the same monetary unit, and start is between zero and the length of prices, inclusive. A start equal to that length leaves no eligible items. No maximum array length or monetary bound is specified.
Examples
maximum_item_counts([5,1,3,2], [[0,4],[2,4],[1,0]]) -> [2,1,0]
The first query can select prices 1 and 2. The second can select only one of the eligible prices 3 and 2 within its budget. The final query cannot afford any eligible item.
maximum_item_counts([2,2,7], [[0,4],[1,2],[3,10]]) -> [2,1,0]
The first query can buy both separately indexed items priced at 2. The last query has an empty eligible suffix.