Help me in solving AIRM problem....resolve issue in this code

My issue

My code

#include <iostream>

using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--){
	   long int n;
	    cin>>n;
	    int ans=1;
	   int a[n],d[n],fre[1439]={0};
	    for(int i=0;i<n;i++){
	        cin>>a[i];
	        fre[a[i]]++;
	    }
	      for(int i=0;i<n;i++){
	        cin>>d[i];
	         fre[d[i]]++;
	    }
	    for(int i=0;i<1439;i++){
	  if(fre[i]>ans) ans = fre[i];}
	  cout<<ans<<endl;
	  
	}
	return 0;
}

Problem Link: AIRM Problem - CodeChef

@deepakjdh31
since the array elements is upto 1439 then u have to take frq array size 1440 or greater .