getting runtime error need help to fix bug ,but the code runs well and the out come also correct , at the time of submission runtime error comes
problem name:movie weekend
#include <bits/stdc++.h>
using namespace std;
int main() {
int t ; cin>>t;
while(t--)
{
int n,L[n],R[n];
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>L[i]; //stored length of movie
}
for(int i=1;i<=n;i++)
{
cin>>R[i]; //stored rating of movie
}
int LCR[n], MXLCR=0;
for(int i=1;i<=n;i++)
{
LCR[i]=L[i]*R[i]; //stored product of the two
MXLCR=max(MXLCR,LCR[i]); //MXLCR holds highest value of LCR
}
vector<pair<int ,int >>v;
for(int i=1;i<=n;i++)
{
v.push_back(make_pair(0,0));
}
for(int i=1;i<=n;i++) //storing rating and index for the same MXLCR holding movies
{
if(MXLCR==LCR[i])
{
v.push_back(make_pair(R[i],i));
}
}
int MaxR=0;
int l=v.size();
for(int j=1;j<=l;j++) //to break tie by highest rating
{
MaxR=max(v[j].first,MaxR);
}
for(int k=1;k<=l;k++)
{
if(MaxR==v[k].first) //geting the MaxR having vector and giving out minimal index
{
cout<<v[k].second<<endl;
break;
}
}
}
return 0;
}