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 int long long
int power(int A, int expo)
{
    if (expo == 0)
        return 1;
    int res = power(A, expo / 2);
    if (expo % 2)
        return res * res * A;
    else
        return res * res;
}
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int factorial(int x)
{
    if (x == 1 || x == 0)
        return 1;
    return (x * factorial(x - 1));
}
class UnionFind{
    private: vector<int> parent,rank;
    public:
        UnionFind(int n){
            rank.assign(n,0);
            parent.assign(n,0);
            iota(parent.begin(),parent.end(),0);
        }
        int find(int x) {
            if(parent[x] == x)
                return x;
            
            return parent[x] = find(parent[x]);
        }

    void UnionSet(int x, int y) {
        int x_parent = find(x);
        int y_parent = find(y);

        if(rank[x_parent] > rank[y_parent]) {
            parent[y_parent] = x_parent;
        } else if(rank[x_parent] < rank[y_parent]) {
            parent[x_parent] = y_parent;
        } else {
            parent[x_parent] = y_parent;
            rank[y_parent]++;
        }
    }
};

int lcm(int a, int b) {
    return (a / gcd(a, b)) * b;
}

int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};

void solve() {
  int n;
  cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  for(int i=1;i<n;i++){
    int x=min(v[i],v[i-1]);
    v[i-1]-=x;
    v[i]-=x;
  }
  int cnt=0;
  for(int i=0;i<n;i++){
    if(v[i]>0) cnt++;
  }
  if(cnt==1 && v[n-1]>0){
    cout<<"Yes\n";
  }
  else{
    cout<<"No\n";
  }
}

signed main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.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 power(int A, int expo)
{
    if (expo == 0)
        return 1;
    int res = power(A, expo / 2);
    if (expo % 2)
        return res * res * A;
    else
        return res * res;
}
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int factorial(int x)
{
    if (x == 1 || x == 0)
        return 1;
    return (x * factorial(x - 1));
}
class UnionFind{
    private: vector<int> parent,rank;
    public:
        UnionFind(int n){
            rank.assign(n,0);
            parent.assign(n,0);
            iota(parent.begin(),parent.end(),0);
        }
        int find(int x) {
            if(parent[x] == x)
                return x;
            
            return parent[x] = find(parent[x]);
        }

    void UnionSet(int x, int y) {
        int x_parent = find(x);
        int y_parent = find(y);

        if(rank[x_parent] > rank[y_parent]) {
            parent[y_parent] = x_parent;
        } else if(rank[x_parent] < rank[y_parent]) {
            parent[x_parent] = y_parent;
        } else {
            parent[x_parent] = y_parent;
            rank[y_parent]++;
        }
    }
};

int lcm(int a, int b) {
    return (a / gcd(a, b)) * b;
}

int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};

void solve() {
  int n;
  cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  for(int i=0;i<n-1;i++){
    int x=min(v[i],v[i+1]);
    v[i+1]-=x;
    v[i]-=x;
    if(v[i]>v[i+1]){
        cout<<"No\n";
        return;
    }
  }
 cout<<"Yes\n";
}

signed main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}