QOJ.ac

QOJ

実行時間制限: 1.0 s メモリ制限: 256 MB 満点: 100 ハック可能 ✓

#9947. 卡拉OK之王

統計

现在是卡拉 OK 时间!DreamGrid 正在游戏《King of Karaoke》中演唱歌曲《Powder Snow》。DreamGrid 演唱的歌曲可以看作一个整数序列 $D_1, D_2, \dots, D_n$,而歌曲的标准版本可以看作另一个整数序列 $S_1, S_2, \dots, S_n$。得分是满足 $1 \le i \le n$ 且 $S_i = D_i$ 的整数 $i$ 的个数。

作为一名优秀的调音师,DreamGrid 可以选择一个整数 $K$(可以是正数、0 或负数)作为他的调音值,并将 $K$ 加到 $D$ 中的每一个元素上。你能通过选择一个合适的调音值来帮助他最大化得分吗?

输入格式

输入包含多组测试数据。第一行包含一个整数 $T$(约 100),表示测试数据的组数。对于每组测试数据:

第一行包含一个整数 $n$ ($1 \le n \le 10^5$),表示序列 $D$ 和 $S$ 的长度。

第二行包含 $n$ 个整数 $D_1, D_2, \dots, D_n$ ($-10^5 \le D_i \le 10^5$),表示 DreamGrid 演唱的歌曲。

第三行包含 $n$ 个整数 $S_1, S_2, \dots, S_n$ ($-10^5 \le S_i \le 10^5$),表示歌曲的标准版本。

保证至多有 5 组测试数据的 $n > 100$。

输出格式

对于每组测试数据,输出一行包含一个整数,表示可能的最大得分。

样例

输入 1

2
4
1 2 3 4
2 3 4 6
5
-5 -4 -3 -2 -1
5 4 3 2 1

输出 1

3
1

说明

对于第一个样例测试数据,DreamGrid 可以选择 $K = 1$,将 $D$ 变为 $\{2, 3, 4, 5\}$。

对于第二个样例测试数据,无论 DreamGrid 选择哪个 $K$,他最多只能得到 1 次匹配。

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.