欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1009A.Game Shopping
Game Shopping
Maxim wants to buy some games at the local game shop. There are games in the shop, the -th game costs .
Maxim has a wallet which can be represented as an array of integers. His wallet contains bills, the -th bill has value .
Games in the shop are ordered from left to right, Maxim tries to buy every game in that order.
When Maxim stands at the position 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 -th game using this bill. After Maxim tried to buy the -th game, he leaves the shop.
Maxim buys the -th game if and only if the value of the first bill (which he takes) from his wallet is greater or equal to the cost of the -th game. If he successfully buys the -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 and array the following process takes place: Maxim buys the first game using the first bill (its value is ), the bill disappears, after that the second bill (with value ) becomes the first one in Maxim's wallet, then Maxim doesn't buy the second game because , the same with the third game, then he buys the fourth game using the bill of value (the third bill becomes the first one in Maxim's wallet) and buys the fifth game using the bill of value .
Your task is to get the number of games Maxim will buy.
Input
The first line of the input contains two integers and () — the number of games and the number of bills in Maxim's wallet.
The second line of the input contains integers (), where is the cost of the -th game.
The third line of the input contains integers (), where is the value of the -th bill from the Maxim's wallet.
Output
Print a single integer — the number of games Maxim will buy.
Note
The first example is described in the problem statement.
In the second example Maxim cannot buy any game because the value of the first bill in his wallet is smaller than the cost of any game in the shop.
In the third example the values of the bills in Maxim's wallet are large enough to buy any game he encounter until he runs out of bills in his wallet.
Samples
5 4
2 4 5 2 4
5 3 4 6
3
5 2
20 40 50 20 40
19 20
0
6 4
4 8 15 16 23 42
1000 1000 1000 1000
4
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |