#K43307. Market Trade Matching
Market Trade Matching
Market Trade Matching
In this problem, you are given several test cases representing a simplified market scenario. For each test case, you have a list of buyer budgets and a list of seller minimum prices. A trade is successful if a buyer's budget is at least as high as a seller's minimum price. Each buyer and seller can only participate in one trade.
Your task is to determine the maximum number of successful trades for each test case. To achieve this, sort the buyers in descending order and the sellers in ascending order. Then, using a two-pointer technique, count the number of pairs where the buyer's budget is not less than the seller's price.
inputFormat
The input consists of multiple test cases. Each test case starts with two integers B and S, representing the number of buyers and sellers respectively. This is followed by B lines of integers (each representing a buyer's budget) and S lines of integers (each representing a seller's minimum price). The input terminates with a line containing "0 0".
outputFormat
For each test case, output a single integer on a new line representing the number of successful trades.
## sample3 3
100
150
200
110
120
130
0 0
2
</p>