欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1972A.Contest Proposal
Contest Proposal
A contest contains problems and the difficulty of the -th problem is expected to be at most . There are already problem proposals and the difficulty of the -th problem is . Initially, both and are sorted in non-decreasing order.
Some of the problems may be more difficult than expected, so the writers must propose more problems. When a new problem with difficulty is proposed, the most difficult problem will be deleted from the contest, and the problems will be sorted in a way that the difficulties are non-decreasing.
In other words, in each operation, you choose an integer , insert it into the array , sort array in non-decreasing order, and remove the last element from it.
Find the minimum number of new problems to make for all .
Input
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains only one positive integer (), representing the number of problems.
The second line of each test case contains an array of length ().
The third line of each test case contains an array of length ().
Output
For each test case, print an integer as your answer in a new line.
Note
In the first test case:
- Propose a problem with difficulty and becomes .
- Propose a problem with difficulty and becomes .
It can be proved that it's impossible to reach the goal by proposing fewer new problems.
In the second test case:
- Propose a problem with difficulty and becomes .
- Propose a problem with difficulty and becomes .
- Propose a problem with difficulty and becomes .
It can be proved that it's impossible to reach the goal by proposing fewer new problems.
Samples
2
6
1000 1400 2000 2000 2200 2700
800 1200 1500 1800 2200 3000
6
4 5 6 7 8 9
1 2 3 4 5 6
2
3
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |