P8837 [ChuanZhi Cup #3 Final] Shop.

Background

disangan333 wants to buy a gift for disangan233, so he goes shopping with you.

Description

There are $n$ students going shopping. The shop has $m$ items. The $i$-th person has $w_i$ units of money, and the $i$-th item costs $c_i$ yuan. Each person can buy at most one item, and each item can be bought at most once. Find the maximum number of people who can buy an item. Constraints: for all testdata, $n, m \leq 10^5$, $w_i, c_i \leq 10^9$.

Input Format

The input has $3$ lines in total. Line $1$ contains two positive integers $n, m$. Line $2$ contains $n$ integers $w_1 \ldots w_n$, where $w_i$ is the amount of money of the $i$-th person. Line $3$ contains $m$ integers $c_1 \ldots c_m$, where $c_i$ is the price of the $i$-th item.

Output Format

Output one integer, the maximum number of people who can buy an item.

Explanation/Hint

Translated by ChatGPT 5