Smart hobber ..why all test cases giving wrong ans..pls check my code

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

long long int solve(vector x)
{
long long int n=x.size();

if(n==0) return 0;
if(n==1) return x[0];
if(n==2) return max(x[0],x[1]);


vector< long long int>dp(n);

dp[0]=x[0];
dp[1]=max(x[0],x[1]);
 
for(int i=2;i<n;i++)
{
	dp[i]=max(dp[i-2]+x[i],dp[i-1]+0);
}
return dp[n-1];

}

int main()
{
int t;
cin>>t;
while(t–)
{
int n;
cin>>n;
vector arr;
for(int i=0;i<n;i++)
{
long long int a;
cin>>a;
arr.push_back(a);
}
long long int ans=solve(arr);
cout<<ans;
}
return 0;
}

hi @divisharoy14_5d0aa86c37c6588a,
refer

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.