QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 256 MB Total points: 100 Hackable ✓

#9947. カラオケの王

Statistics

カラオケの時間です! DreamGrid はゲーム King of Karaoke で曲 Powder Snow を歌っています。DreamGrid が歌った曲は整数列 $D_1, D_2, \ldots, D_n$ とみなせ、曲の標準版は別の整数列 $S_1, S_2, \ldots, S_n$ とみなせます。得点は、$1 \le i \le n$ かつ $S_i = D_i$ を満たす整数 $i$ の個数です。

調整が得意な DreamGrid は、整数 $K$(正でも $0$ でも負でもかまいません)を調として選び、$D$ のすべての要素に $K$ を加えることができます。適切な調を選んで得点を最大化するのを手伝ってください。

入力

複数のテストケースがあります。入力の最初の行には、テストケース数を表す整数 $T$(約 100)が含まれます。各テストケースについて、次の形式で与えられます。

最初の行には、列 $D$ と $S$ の長さを表す整数 $n$ ($1 \le n \le 10^5$) が含まれます。

次の行には、DreamGrid が歌った曲を表す $n$ 個の整数 $D_1, D_2, \ldots, D_n$ ($-10^5 \le D_i \le 10^5$) が含まれます。

3 行目には、曲の標準版を表す $n$ 個の整数 $S_1, S_2, \ldots, S_n$ ($-10^5 \le S_i \le 10^5$) が含まれます。

$n > 100$ であるテストケースは最大 5 個であることが保証されます。

出力

各テストケースについて、取り得る最大得点を表す整数を 1 行に一つ出力してください。

入出力例

入力 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.