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$)이 주어집니다.

세 번째 줄에는 노래의 표준 버전을 나타내는 $n$개의 정수 $S_1, S_2, \ldots, S_n$ ($-10^5 \le S_i \le 10^5$)이 주어집니다.

$n > 100$인 테스트 케이스는 최대 5개임이 보장됩니다.

출력

각 테스트 케이스마다 가능한 최대 점수를 나타내는 정수를 한 줄에 하나 출력하세요.

예제

입력 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.