Max-query runtime error

code is compiles successfully and giving correct output for sample input…but giving rumtime error for test cases

Hey
Can you post your code?

#include
#include
#include
using namespace std;
void build(int arr,vector tree,int i,int j,int index){
if(i==j){
vector v;
v.push_back(arr[i]);
tree[index]=v;
return;
}
int mid=(i+j)/2;
build(arr,tree,i,mid,2
index);
build(arr,tree,mid+1,j,2
index+1);
vectorarr3(j-i+1,0);

merge(tree[2*index].begin(), tree[2*index].end(), tree[2*index+1].begin(), tree[2*index+1].end(), arr3.begin()); 
tree[index]=arr3;
return;

}
int query(vector *tree,int st,int end,int i,int j,int index,int p){

if(st>j or end<i){
    return 0;
}
if(st<=i and end>=j){
    int a=tree[index].end()-lower_bound(tree[index].begin(),tree[index].end(),p);
    

    return a;
}
int mid=(i+j)/2;
return query(tree,st,end,i,mid,2*index,p)+query(tree,st,end,mid+1,j,2*index+1,p);

}
int main() {
int n=0;
cin>>n;
if(n==0){
return 1;
}
int arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];

}
vector<int> tree[4*n+1];
build(arr,tree,0,n-1,1);

int k,a,b,c;
cin>>k;
for(int i=0;i<k;i++){
    cin>>a>>b>>c;
cout<<query(tree,a-1,b-1,0,n-1,1,c)<<endl;

}

}

Can you post your code as a coding blocks ide link please

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.