LIS modified ,plz tell me why i am getting wrong answer

#include<bits/stdc++.h>
using namespace std;

long long int lis( long long int arr[], int n ,long long int w[])
{

for (int i = 1; i < n; i++ )  
{ 
   
  long long  int m=INT_MIN;
    for (int j = 0; j < i; j++ )  { 
        if ( arr[i] >arr[j] )  {

m=max(m,w[j]+w[i]);
}
}
w[i]=m;
}
return *max_element(w, w+n);
}

int main()
{ int t;
cin>>t;
while(t–){
int n ;
cin>>n;
long long int arr[n];
long long int w[n];
int i;
for(i=0;i<n;i++)
cin>>arr[i];
for(i=0;i<n;i++)
cin>>w[i];

printf("%ld\n", lis( arr, n,w ));  

}
return 0;
}

9
1 2 3 4 2 3 4 1 2
1 1 1 1 5 1 1 9 8

Run your code for this test case
Output should be 17 , but your code gives 9.
And also check the constraints , your logic will give TLE in end corner cases.