QOJ.ac

QOJ

Límite de tiempo: 1.0 s Límite de memoria: 256 MB Puntuación total: 100 Hackeable ✓

#18141. 比赛提案

Estadísticas

一场比赛包含 $n$ 道题,预计第 $i$ 道题的难度至多为 $b_i$。目前已经有了 $n$ 个题目提案,第 $i$ 个题目的难度为 $a_i$。最初,$a_1, a_2, \dots, a_n$ 和 $b_1, b_2, \dots, b_n$ 都已按非降序排序。

有些题目可能比预期的要难,因此命题人必须提出更多的题目。当提出一个难度为 $w$ 的新题时,比赛中难度最大的题目将被删除,并且所有题目将重新按难度非降序排序。

换句话说,在每次操作中,你选择一个整数 $w$,将其插入数组 $a$ 中,将数组 $a$ 按非降序排序,并移除其中的最后一个元素。

求使得对于所有 $i$ 均满足 $a_i \le b_i$ 所需的最少新题数量。

输入格式

每个测试点包含多个测试用例。第一行包含测试用例的数量 $t$ ($1 \le t \le 100$)。接下来是测试用例的描述。

每个测试用例的第一行仅包含一个正整数 $n$ ($1 \le n \le 100$),表示题目的数量。

每个测试用例的第二行包含一个长度为 $n$ 的数组 $a$ ($1 \le a_1 \le a_2 \le \dots \le a_n \le 10^9$)。

每个测试用例的第三行包含一个长度为 $n$ 的数组 $b$ ($1 \le b_1 \le b_2 \le \dots \le b_n \le 10^9$)。

输出格式

对于每个测试用例,在新的一行中输出一个整数作为你的答案。

样例

输入样例 1

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

输出样例 1

2
3

说明

在第一个测试用例中:

  • 提出一个难度为 $w = 800$ 的新题,数组 $a$ 变为 $[800, 1000, 1400, 2000, 2000, 2200]$。
  • 提出一个难度为 $w = 1800$ 的新题,数组 $a$ 变为 $[800, 1000, 1400, 1800, 2000, 2000]$。

可以证明,无法通过提出更少的新题来达到目标。

在第二个测试用例中:

  • 提出一个难度为 $w = 1$ 的新题,数组 $a$ 变为 $[1, 4, 5, 6, 7, 8]$。
  • 提出一个难度为 $w = 2$ 的新题,数组 $a$ 变为 $[1, 2, 4, 5, 6, 7]$。
  • 提出一个难度为 $w = 3$ 的新题,数组 $a$ 变为 $[1, 2, 3, 4, 5, 6]$。

可以证明,无法通过提出更少的新题来达到目标。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.