Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;

#define improve ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#define ll long long
#define S second
#define F first
#define vll vector<ll>
#define el '\n'
#define yes cout << "YES"<< "\n"
#define no cout << "NO"<< "\n"
#define all(v) v.begin(),v.end()
#define allR(v) (v).rbegin(), (v).rend()
#define sz(x) (long long)x.size()
#define ISON(n, k) ((n>>k)&1)
#define Power(n) !(n&(n-1))
#define arrayin(i, n) for(int i = 0; i < n; i++)

void IOF() {
    //    freopen("bye.in", "r", stdin);
#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#endif
}

char di[] = {'D', 'L', 'U', 'R'};
int dx[] = {1, -1, 0, 0, -1, -1, 1, 1};
int dy[] = {0, 0, 1, -1, -1, 1, -1, 1};
//const int N = 1e6;
pair<int, int> d1[] = {
    {1, 0}, // Down
    {-1, 0}, // Up
    {0, 1}, // Right
    {0, -1}, // Left
    {-1, -1}, // Top-left diagonal
    {-1, 1}, // Top-right diagonal
    {1, -1}, // Bottom-left diagonal
    {1, 1}
}; // Bottom-right diagonal

const ll N = 2e5 + 5;
const ll M = 1e6 + 5;

int power(int b, int p) {
    if (p == 0)
        return 1;
    int r = power(b, p / 2);
    r *= r;
    if (p & 1) {
        r *= b;
    }
    return r;
}


void solve() {
    ll n;
    cin >> n;
    vector<ll> v(n);
    for (ll i = 0; i < n; i++) {
        cin >> v[i];
    }
    if (is_sorted(all(v))) {
        yes;
        return;
    }
    for (ll i = 0; i < n - 1; i++) {
        if (v[i] - v[i + 1] >= 1) {
            no;
            return;
        } else {
            i++;
        }
    }
    yes;
}


int main() {
    improve
    IOF();
    ll tt = 1;
    cin >> tt;
    while (tt--) {
        solve();
    }

    return 0;
}


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>

using namespace std;

#define improve ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#define ll long long
#define S second
#define F first
#define vll vector<ll>
#define el '\n'
#define yes cout << "YES"<< "\n"
#define no cout << "NO"<< "\n"
#define all(v) v.begin(),v.end()
#define allR(v) (v).rbegin(), (v).rend()
#define sz(x) (long long)x.size()
#define ISON(n, k) ((n>>k)&1)
#define Power(n) !(n&(n-1))
#define arrayin(i, n) for(int i = 0; i < n; i++)

void IOF() {
    //    freopen("bye.in", "r", stdin);
#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#endif
}

char di[] = {'D', 'L', 'U', 'R'};
int dx[] = {1, -1, 0, 0, -1, -1, 1, 1};
int dy[] = {0, 0, 1, -1, -1, 1, -1, 1};
//const int N = 1e6;
pair<int, int> d1[] = {
    {1, 0}, // Down
    {-1, 0}, // Up
    {0, 1}, // Right
    {0, -1}, // Left
    {-1, -1}, // Top-left diagonal
    {-1, 1}, // Top-right diagonal
    {1, -1}, // Bottom-left diagonal
    {1, 1}
}; // Bottom-right diagonal

const ll N = 2e5 + 5;
const ll M = 1e6 + 5;

int power(int b, int p) {
    if (p == 0)
        return 1;
    int r = power(b, p / 2);
    r *= r;
    if (p & 1) {
        r *= b;
    }
    return r;
}


void solve() {
    ll n;
    cin >> n;
    vector<ll> v(n);
    for (ll i = 0; i < n; i++) {
        cin >> v[i];
    }
    for (ll i = 0; i < n - 1; i++) {
        v[i] -= min(v[i], v[i + 1]);
        v[i + 1] -= min(v[i + 1], v[i]);
        if (v[i + 1] < v[i]) {
            no;
            return;
        }
    }
    yes;
}


int main() {
    improve
    IOF();
    ll tt = 1;
    cin >> tt;
    while (tt--) {
        solve();
    }

    return 0;
}