King of Karaoke
Time Limit: 1000 msMemory Limit: 65536 KB
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 D_1, D_2, \dots, D_n, and the standard version of the song can be considered as another integer sequence S_1, S_2, \dots, S_n. The score is the number of integers i satisfying 1≤i≤n and Si=Di.
As a good tuner, DreamGrid can choose an integer K (can be positive, 0, or negative) as his tune and add K to every element in D. Can you help him maximize his score by choosing a proper tune?
Input
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 n (1≤n≤105), indicating the length of the sequences D and S.
The second line contains n integers D_1, D_2, \dots, D_n (−105≤Di≤105), indicating the song performed by DreamGrid.
The third line contains n integers S_1, S_2, \dots, S_n (−105≤Si≤105), indicating the standard version of the song.
It's guaranteed that at most 5 test cases have n>100.
Output
For each test case output one line containing one integer, indicating the maximum possible score.
Sample Input
2 4 1 2 3 4 2 3 4 6 5 -5 -4 -3 -2 -1 5 4 3 2 1Sample Output
3 1Hint
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
int T;
int n;
int x;
int a[100010];
cin>>T;
while(T--)
{
int sum=0;
int maxx=0;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
for(int i=0;i<n;i++)
{
cin>>x;
a[i]=a[i]-x;
// cout<<a[i]<<endl;
}
sort(a,a+n);
for(int i=1;i<n;i++)
{
if(a[i]==a[i-1])
{
sum++;
if(sum>maxx)
{
maxx=sum;
}
}
else
{
sum=0;
}
// cout<<maxx<<endl;
}
cout<<maxx+1<<endl;
}
return 0;
}