← 返回题目列表

Codeforces · 1009/A

A. 游戏购物

中文机器翻译题面 查看原题

Maxim 想在当地的游戏店购买一些游戏。商店里有 $$$n$$$ 游戏,第 $$$i$$$ 游戏的费用为 $$$c_i$$$。

Maxim 有一个可以表示为整数数组的钱包。他的钱包里有$$$m$$$钞票,第$$$j$$$钞票的价值为$$$a_j$$$。

商店中的游戏是从左到右排序的,Maxim 尝试按该顺序购买所有游戏。

When Maxim stands at the position $$$i$$$ in the shop, he takes the first bill from his wallet (if his wallet is empty then he proceeds to the next position immediately) and tries to buy the $$$i$$$-th game using this bill.在马克西姆试图购买第 $$$n$$$ 游戏后,他离开了商店。

当且仅当他从钱包中取出的第一张账单的价值大于或等于第 $$$i$$$ 游戏的费用时,Maxim 才会购买第 $$$i$$$ 游戏。 If he successfully buys the $$$i$$$-th game, the first bill from his wallet disappears and the next bill becomes first. Otherwise Maxim leaves the first bill in his wallet (this bill still remains the first one) and proceeds to the next game.

For example, for array $$$c = [2, 4, 5, 2, 4]$$$ and array $$$a = [5, 3, 4, 6]$$$ the following process takes place: Maxim buys the first game using the first bill (its value is $$$5$$$), the bill disappears, after that the second bill (with value $$$3$$$) becomes the first one in Maxim's wallet, then Maxim doesn't buy the second game because $$$c_2 > a_2$$$, the same with the third game, then he buys the fourth game using the bill of value $$$a_2$$$ (the third bill becomes the first one in Maxim's wallet) and buys the fifth game using the bill of value $$$a_3$$$.

Your task is to get the number of games Maxim will buy.

输入

The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 1000$$$) — the number of games and the number of bills in Maxim's wallet.

输入的第二行包含 $$$n$$$ 整数 $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le 1000$$$),其中 $$$c_i$$$ 是第 $$$i$$$ 游戏的成本。

输入的第三行包含 $$$m$$$ 整数 $$$a_1, a_2, \dots, a_m$$$ ($$$1 \le a_j \le 1000$$$),其中 $$$a_j$$$ 是 Maxim 钱包中第 $$$j$$$ 钞票的价值。

输出

Print a single integer — the number of games Maxim will buy.

示例

输入 #1

5 4
2 4 5 2 4
5 3 4 6

输出 #1

3

输入 #2

5 2
20 40 50 20 40
19 20

输出 #2

0

输入 #3

6 4
4 8 15 16 23 42
1000 1000 1000 1000

输出 #3

4

注意

第一个示例在问题陈述中进行了描述。

在第二个示例中,Maxim 无法购买任何游戏,因为他钱包中第一张账单的价值小于商店中任何游戏的费用。

在第三个示例中,Maxim 钱包中的钞票价值足够大,可以购买他遇到的任何游戏,直到他用完钱包中的钞票为止。