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

Solution 1 (runtime: 93 ms):
#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
template < typename T >
using ordered_set = tree < T, null_type, less < T >,
rb_tree_tag, tree_order_statistics_node_update >;
 
template < typename T >
using ordered_multiset = tree < T, null_type, less_equal < T >,
rb_tree_tag, tree_order_statistics_node_update >;
 
#define min_nums(n) st.order_of_key(n)
#define value(n) st.find_by_order(n)
#define ll long long
#define ull unsigned long long
#define mx 1e9
#define mn -1e9

bool sorted( int n,int arr[] )
{
    for ( int i = 1 ; i < n ; i++ )
    {
        if ( arr[i] < arr[i-1] ) return 0 ;
    }
    return 1 ;
}


int main ()
{
    ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
    #endif

    int t ;
    cin >> t;
    while ( t-- )
    {
        int n ;
        cin >> n ;
        int arr[n] ;
        for ( int i = 0 ; i < n ; i++ ) cin >> arr[i] ;

        for ( int i = 0 ; i < n-1 ; i++ )
        {
            int num = min(arr[i], arr[i+1] ) ;
            arr[i] -= num ;
            arr[i+1]-= num ;
        }

        bool test = 1 ;
        for ( int i = 0 ; i < n-1 ; i++ )
        {
            if ( arr[i] > arr[i+1] ){ test = false ; }
        }
        if ( test ) cout << "YES\n" ;
        else cout << "NO\n" ;
    }

}

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

#define OJ

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<>, rb_tree_tag,
/*****/ tree_order_statistics_node_update> indexed_set;
using ll = long long;
using ld = long double;
typedef vector<vector<int>> Graph;
#define F first
#define S second
#define pb push_back
#define f(i, a, b)  for(int i = a; i < b; i++)
#define iv vector<int>
#define intInf 2e9
#define llInf 2e18
#define el "\n"
#define print(a) for (auto x: a) cout << x << " "; cout << endl
#define printMap(a) for (auto x: a) cout << x.F << " " << x.S << endl; cout << endl
#define printPair(x) cout << x.F << " " << x.S; cout << endl
#define printSt(st) for(; not st.empty(); st.pop()) cout << st.top() << " ";
#define scan_arr(arr) for(auto &x : arr) cin >> x;
#define all(a)  a.begin(), a.end()
#define as_sort(a) sort(all(a))
#define ds_sort(a) sort(all(a), greater<>())
#define rev(a) reverse(all(a))
ll cceil(const ll a, const ll b) { return (a + b - 1) / b; }
// ********** The road to Expert ********** //


void solve() {
    int n; cin >> n;
    vector<int> vec(n);
    for(int i = 0; i < n; i++) {
        cin >> vec[i];
    }
    bool ok = true;
    for(int i = 0; i < n - 1; i++) {
        if (vec[i] <= vec[i + 1]) {
            vec[i + 1] -= vec[i];
            vec[i] = 0;
        }
        else {
            ok = false;
        }
    }
    if (ok) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}


int main() {
#ifndef OJ
    freopen(R"(input.txt)", "r", stdin);
    freopen(R"(output.txt)", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    clock_t z = clock();
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }

    cerr << "Run Time : " << (static_cast<double>(clock() - z) / CLOCKS_PER_SEC) << endl;
    return 0;
}