Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ll long long
#define pb push_back
#define eb emplace_back
#define endl '\n'

using namespace std;

const int MOD = 1000000007;

#ifdef KRISHNA
#include "handle_debug.hpp"
#define debug(...)                    \
    cout << '[';                      \
    debug_print(#_VA_ARGS, VA_ARGS_); \
    cout << "]\n";
#else
#define debug(...)
#endif

ll gcd(ll a, ll b)
{
    while (b)
    {
        ll t = a % b;
        a = b;
        b = t;
    }
    return a;
}

bool isPrime(ll n)
{
    if (n <= 1)
    {
        return false;
    }
    for (int i = 2; i <= sqrt(n); i++)
    {
        if (n % i == 0)
        {
            return false;
        }
    }
    return true;
}

int isSubstring(string s1, string s2)
{
    if (s2.find(s1) != string::npos)
        return s2.find(s1);
    return -1;
}

ll fac(ll n)
{
    ll f = 1;
    if (n == 0 || n == 1)
        return 1;
    else
    {
        for (ll i = 2; i <= n; i++)
        {
            f *= i;
        }
        return f;
    }
}

int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<int> vec(n,0);
        for(int i=0; i<n; i++){
            cin>>vec[i];
        }
        int flag=1;
        for (int i = 0; i < n-1; i+=2)
        {
           int k=min(vec[i], vec[i+1]);
           vec[i]=vec[i]-k;
           vec[i+1]=vec[i+1]-k;

           if(vec[i]>vec[i+1]){
            flag=0;
            break;
           }
        }

        if(flag) cout<<"YES"<<endl;
        else{
            cout<<"NO"<<endl;
        }
        


    }
    return 0;
}

Submission (verdict: Accepted):
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ll long long
#define pb push_back
#define eb emplace_back
#define endl '\n'

using namespace std;

const int MOD = 1000000007;

#ifdef KRISHNA
#include "handle_debug.hpp"
#define debug(...)                    \
    cout << '[';                      \
    debug_print(#_VA_ARGS, VA_ARGS_); \
    cout << "]\n";
#else
#define debug(...)
#endif

ll gcd(ll a, ll b)
{
    while (b)
    {
        ll t = a % b;
        a = b;
        b = t;
    }
    return a;
}

bool isPrime(ll n)
{
    if (n <= 1)
    {
        return false;
    }
    for (int i = 2; i <= sqrt(n); i++)
    {
        if (n % i == 0)
        {
            return false;
        }
    }
    return true;
}

int isSubstring(string s1, string s2)
{
    if (s2.find(s1) != string::npos)
        return s2.find(s1);
    return -1;
}

ll fac(ll n)
{
    ll f = 1;
    if (n == 0 || n == 1)
        return 1;
    else
    {
        for (ll i = 2; i <= n; i++)
        {
            f *= i;
        }
        return f;
    }
}

int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<int> vec(n,0);
        for(int i=0; i<n; i++){
            cin>>vec[i];
        }
        int flag=1;
        for (int i = 0; i < n-1; i++)
        {
           int k=min(vec[i], vec[i+1]);
           vec[i]=vec[i]-k;
           vec[i+1]=vec[i+1]-k;

           if(vec[i]>vec[i+1]){
            flag=0;
            break;
           }
        }

        if(flag) cout<<"YES"<<endl;
        else{
            cout<<"NO"<<endl;
        }
        


    }
    return 0;
}