Problem: 2060D - Subtract Min Sort
Language: c++17 

Solution 1 (runtime: 358 ms):
    #include<bits/stdc++.h>
    #include<ext/pb_ds/assoc_container.hpp>
    #include<ext/pb_ds/tree_policy.hpp>

    using namespace std;
    using namespace __gnu_pbds;


    #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    #define rep(i,n) for (int i = 0; i < n; i++)
    #define mod 1000000007
    #define pb push_back
    #define ff first
    #define ss second
    #define pii pair<int,int>
    #define vi vector<int>
    #define vll vector<long long>
    #define vvi vector<vector<int>>
    #define vvll vector<vector<long long>>
    #define ll long long
    #define INF 2000000000
    #define pyes cout<<"YES"<<endl
    #define pno cout<<"NO"<<endl

    const double PI = 3.141592653589793238460;

    // pbds
    typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 
    // find_by_order - to find the kth element ( returns iterator, indexing starting from 0 , i.e 0th element is 1st element in set)
    // order_of_key -  reuturn no of elements strictly less than key 


    const int N = 200001;
    vi dr={0,0,-1,1};
    vi dc = {1,-1,0,0};



    ll seg[4*N];
    ll seg_min[4*N];

     

    void build( ll ar[], int ind, int arr_l, int arr_r) {
        if (arr_l == arr_r) {
            seg[ind] = ar[arr_l];
        } else {
            int arr_m = (arr_l + arr_r) / 2;
            build(ar, ind*2, arr_l, arr_m);
            build(ar,ind*2+1, arr_m+1, arr_r);
            seg[ind] = max(seg[ind*2],seg[ind*2 + 1]);
        }
    }
     

    ll query(int v, int arr_l, int arr_r, int q_l,int q_r) {

        if(arr_l>q_r || arr_r<q_l){
            return INT_MIN ;
        }


        if(arr_l>=q_l && arr_r<=q_r){
           

            return seg[v];


        }
        else{

            int arr_m = (arr_l+arr_r)/2;

            ll ans = max(query(v*2,arr_l,arr_m,q_l,q_r) , query(v*2 + 1 ,arr_m+1,arr_r,q_l,q_r));

         
            return ans;

        }

       

        
    }

    void update(int v, int arr_l, int arr_r,int pos, ll val) {

        if(arr_l==arr_r){
            seg[v]=val;

        }
        else{
            int arr_m = (arr_l+arr_r)/2;
            if(pos<=arr_m){
                update(v*2,arr_l,arr_m,pos,val);

            }
            else{
                update(v*2 + 1 ,arr_m+1,arr_r,pos,val);

            }

            seg[v]= min(seg[v*2],seg[v*2 + 1]);


        }   
       
    }


    // bool comp(pair<ll,ll> a, pair<ll,ll> b){

    //     return (a.first==b.first ? )

    // }
    // ll mod = 1e9 + 7;

    void dfs(ll node , vll adj[],vll &vis, ll f, ll s){
        vis[node]=1;

        for(auto child : adj[node]){
            if(child!=f && child!=s && vis[child]==0){
                dfs(child,adj,vis,f,s);
            }
        }
    }


    ll recur(ll ind ,ll sum,ll prev,ll &n, vll &arr,vector<vector<vector<ll>>> &dp){

        if(ind==n){
            return 1;
        }

        if(dp[ind][sum][prev]!=-1){
            return dp[ind][sum][prev];
        }

        if(prev==1){
            ll ans =0;

            if(arr[ind]==sum){
                ans+=recur(ind+1,sum,1,n,arr,dp);
            }
            ans+=recur(ind+1,sum+1,0,n,arr,dp);

            return dp[ind][sum][prev]=ans;

        }
        else{

            if(arr[ind]==sum){
                return dp[ind][sum][prev]=recur(ind+1,sum,1,n,arr,dp);
            }

        }

        return dp[ind][sum][prev]=0;
    }
 
int main() {
    // solve();

    ll t;
    cin>>t;
    while(t--){
        ll n;
        cin>>n;

        vll arr(n,0);

        rep(i,n){
            cin>>arr[i];
        }
        bool ans=1;

        for(int i=1;i<n;i++){
            if(arr[i]>=arr[i-1]){
                arr[i]=arr[i]-arr[i-1];
            }
            else{
                ans=0;
                break;
            }
        }

        if(ans){
            pyes;
        }
        else{
            pno;
        }


    }

  return 0;
 
}

Solution 2 (runtime: 124 ms):
//~imran~

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long long t;
    cin>>t;
    while(t--){
       long long n,i,j;
        cin>>n;
        int arr[200005];
        for( i=0;i<n;i++){
            cin>>arr[i];
        }
        int x=0;
        for( j=0;j<n-1;j++){
               if( arr[j]>arr[j+1]) x=1;
               arr[j+1]-=arr[j];
            }
       if(x==0) cout << "YES\n";
        else cout<<"NO\n";    
    }
    return 0;
}