Maximum sum path in two arrays

Not getting bitonic subsequence

@kumarakash121005 what is ur actually question is??

maximum sum path in two arrays

#include
using namespace std;

int main() {

long long int t;
cin>>t;

while(t–){
long long int n,m;
cin>>n>>m;
long long int a[n];
long long int b[m];
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int i=0;i<m;i++){
cin>>b[i];
}

  long long  int i=0;
long long int j=0;
long long int sum1=0,sum2=0;
long long int result=0;
while(i<n && j<m){
   if(a[i]<b[j]){
     sum1+=a[i++];
	 
	 
	 
   }
   else if(a[i]>b[j]){
	   sum2+=b[j++];

   }
   else{
	   result+=max(sum1,sum2)+a[i];
	   i++;
	   j++;
	   sum1=0;
	   sum2=0;
   }
}

 while(i<n){
   sum1+=a[i++];

}
while(j<m){
sum2+=b[j++];

}
result+=max(sum1,sum2);
cout<<result;

}

return 0;

}
it shows wrong answer

@kumarakash121005 try this

@kumarakash121005 if still wrong just take int mod =1e9+7 and result=result%mod then return it

@kumarakash121005 is it solve ??
u understood the logic aur implementation??

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.