Help me in solving DISJOINTSUB problem

My issue

My code is prefectly giving true answer of those test case but when i submit , no one test case is true.

My code

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

void fun(){
    int size;
    //cout << "enter size of array";
    cin >> size;
    
    vector<int> arr (size);
    vector<bool> isAdded (size, false);
    
    // getting array
    for(int i=0; i<size; i++){
        //cout<<"enter arr["<<i<<"]";
        cin >> arr[i];
    }
    
    int maxi = INT_MIN;
    for(int i=1; i<size;){
        if(arr[i] < arr[i-1]){
            maxi = max(maxi, arr[i-1] - arr[i]);
            isAdded[i] = true;
            i+=2;
        }
        else{
            i++;
        }
    }
    
    for(int i=1 ; i<size; i++){
        if(isAdded[i]){
            arr[i] += maxi;
        }
    }
    
    for(int i=1 ; i<size; i++){
        if(arr[i] < arr[i-1]){
            
            cout << "NO";
            return;
        }
    }
    cout << "YES";
}

int main() {
	// your code goes here
    int t;
    cin >> t;
    while(t--){
        fun();
    }
    
}

Problem Link: Disjoint Non-Decreasing Array Practice Coding Problem - CodeChef

@bhanderidhruv9
here refer the following c++ code

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

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    int n;
	    cin>>n;
	    int a[n];
	    for(int i=0;i<n;i++)
	    {
	        cin>>a[i];
	    }
	    int xmin=0;
	    int xmax=INT_MAX;
	    int ch=0,prev=-1;
	    for(int i=1;i<n;i++)
	    {
	        if(a[i]<a[i-1])
	        {
	            if(prev==-1)
	            {
	                prev=i;
	                xmin=max(xmin,a[i-1]-a[i]);
	                if(i!=n-1)
	                {
	                    xmax=min(a[i+1]-a[i],xmax);
	                }
	                i++;
	            }
	            else
	            {
	                if(a[i]<a[prev])
	                {
	                    ch=1;
	                    break;
	                }
	                else
	                {
    	                prev=i;
    	                xmin=max(xmin,a[i-1]-a[i]);
    	                if(i!=n-1)
    	                {
    	                    xmax=min(a[i+1]-a[i],xmax);
    	                }
    	                i++;
	                }
	            }
	        }
	    }
	    if(ch==1||xmax<xmin)
	    cout<<"NO";
	    else
	    cout<<"YES";
	    cout<<endl;
	}
	return 0;
}