can some one tell me whats wrong with my code

int Solution::candy(vector &A) {

int n=A.size();

int dp[n];

int flag=1;

int sum=0;

for(int i=0;i<n;i++){

dp[i]=1;

}

for(int i=1;i<A.size();i++){

if(A[i]==A[i-1])

continue;

```
else if(A[i]>A[i-1] && dp[i]<=dp[i-1] )
dp[i]=dp[i]+1;
else if(A[i-1]>A[i] && dp[i-1]<=dp[i] ){
dp[i-1]=dp[i]+1;
if(i-1!=0)
i=i-2;
}
}
int ag=0;
for(int i=0;i<n;i++)
ag+=dp[i];
return ag;
```

}