It's Karaoke time! DreamGrid is performing the song Powder Snow in the game King of Karaoke. The song performed by DreamGrid can be considered as an integer sequence , and the standard version of the song can be considered as another integer sequence . The score is the number of integers satisfying and .
As a good tuner, DreamGrid can choose an integer (can be positive, 0, or negative) as his tune and add to every element in . Can you help him maximize his score by choosing a proper tune?
There are multiple test cases. The first line of the input contains an integer (about 100), indicating the number of test cases. For each test case:
The first line contains one integer (), indicating the length of the sequences and .
The second line contains integers (), indicating the song performed by DreamGrid.
The third line contains integers (), indicating the standard version of the song.
It's guaranteed that at most 5 test cases have .
OutputFor each test case output one line containing one integer, indicating the maximum possible score.
Sample Input2 4 1 2 3 4 2 3 4 6 5 -5 -4 -3 -2 -1 5 4 3 2 1Sample Output
3 1Hint
For the first sample test case, DreamGrid can choose and changes to .
For the second sample test case, no matter which DreamGrid chooses, he can only get at most 1 match.
#include"cstdio"
#include"cstring"
#include"algorithm"
using namespace std;
int xx[100005];
int yy[100005];
int pp[400005];
int main()
{
int t , a;
while(~scanf("%d",&t))
{
for(int i = 0 ; i < t ; i ++)
{
scanf("%d",&a);
int k = 0;
int e = 0 , b = 0;
for(int j = 0 ; j < a ; j ++)
{
scanf("%d",&xx[j]);
}
for(int j = 0 ; j < a ; j ++)
{
scanf("%d",&yy[j]);
pp[j] = xx[j] - yy[j];
}
sort(pp,pp+a);
for(int j = 1 ; j < a ; j ++)
{
if(pp[j] == pp[j-1])
b++;
if(pp[j] != pp[j-1])
b = 0;
if(b > k)
k = b;
}
printf("%d\n",k+1);
}
}
return 0;
}