Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
 
#define int long long int
#define ll long long
 
typedef vector<long long> vt;
typedef pair<long long,long long> pi;
typedef vector<pair<long long,long long>> vpi;
 
#define loop(n) for (long long i = 0; i < n; i++)
#define all(s) (s).begin(), (s).end()
#define gcd(a, b) __gcd(a, b)
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define ppb pop_back
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define f(ind, i, m) for (ll (ind) = (i); (ind) <= (m); (ind)++)
 
#define ull unsigned long long
#define ff first
#define ss second
const ll mod = 1e9 + 7;
 
bool sortbysec(const pair<int, int>& a, const pair<int, int>& b) { return (a.second < b.second); }
void printa(vector<int>& v) { for (auto i : v) { cout << i << " "; } cout << endl; }
void printmp(map<int, int> mp) { for (auto i : mp) { cout << i.first << " " << i.second << endl; } }
ll BinExpItr(ll a, ll b) { ll ans = 1; while (b) { if (b & 1) ans = (ans * 1ll * a) % mod; a = (a * 1ll * a) % mod; b >>= 1; } return ans; }
 
void solve() 
{ 
    ll n;
    cin>>n;
    vt v(n);
    f(i,0,n-1)
    {
        cin>>v[i];
    }

   bool flag=true;

   for(int i=0;i<n-1;i++)
   {
         if(v[i]<v[i+1])
         {
             ll mini=min(v[i],v[i+1]);
             v[i]-=mini;
             v[i+1]-=mini;

         }else if(v[i]>v[i+1])
         {
            flag=false;
         }
   }

  if(flag)
  yes;
  else
  no;





 
    
 
}
 
int32_t main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
 
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
 
#define int long long int
#define ll long long
 
typedef vector<long long> vt;
typedef pair<long long,long long> pi;
typedef vector<pair<long long,long long>> vpi;
 
#define loop(n) for (long long i = 0; i < n; i++)
#define all(s) (s).begin(), (s).end()
#define gcd(a, b) __gcd(a, b)
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define ppb pop_back
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define f(ind, i, m) for (ll (ind) = (i); (ind) <= (m); (ind)++)
 
#define ull unsigned long long
#define ff first
#define ss second
const ll mod = 1e9 + 7;
 
bool sortbysec(const pair<int, int>& a, const pair<int, int>& b) { return (a.second < b.second); }
void printa(vector<int>& v) { for (auto i : v) { cout << i << " "; } cout << endl; }
void printmp(map<int, int> mp) { for (auto i : mp) { cout << i.first << " " << i.second << endl; } }
ll BinExpItr(ll a, ll b) { ll ans = 1; while (b) { if (b & 1) ans = (ans * 1ll * a) % mod; a = (a * 1ll * a) % mod; b >>= 1; } return ans; }
 
void solve() 
{ 
    ll n;
    cin>>n;
    vt v(n);
    f(i,0,n-1)
    {
        cin>>v[i];
    }

   bool flag=true;

   for(int i=0;i<n-1;i++)
   {
         if(v[i]<=v[i+1])
         {
             ll mini=min(v[i],v[i+1]);
             v[i]-=mini;
             v[i+1]-=mini;

         }else if(v[i]>v[i+1])
         {
            flag=false;
         }
   }

  if(flag)
  yes;
  else
  no;





 
    
 
}
 
int32_t main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
 
    return 0;
}