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

Code 1:
/*



وَهُوَ مَعَكُمْ أَيْنَ مَا كُنْتُم

_       _                           _          _               _   _

/ \     | |                         | |        | |             | | (_)

/   \    | |         |FREE|          | |   ___  | |__     __ _  | |  _

/ / \ \   | |       |PALESTINE|   _   | |  / _ \ | '_ \   / _` | | | | |

/ __ __ \  | |____                | |__| | |  __/ | |_) | | (_| | | | | |

/_/     \_\ |______|                \____/   \___| |_.__/   \__,_| |_| |_|



*/



#include <bits/stdc++.h>

using namespace std;

#define all(v) v.begin(), v.end()



#define endl '\n'

#define int long long

void tracking(vector<int> v) {

for (int i = 0; i < v.size(); i++) {

cout << v[i] << " ";

}

cout << endl;

}

void Input(vector<int> &v) {

for (int &x : v) {

cin >> x;

}

}



#define posative(a) max(a, 0LL);

#define FAST                                                                   \

ios_base::sync_with_stdio(0);                                                \

cin.tie(nullptr);                                                            \

cout.tie(nullptr);

#define fileIO                                                                 \

freopen("input.txt", "r", stdin);                                            \

freopen("output.txt", "w", stdout)



//-----------------------------------------------------------------------------------------------------------------------------------



void solve() {

int n;

cin >> n;

vector<int> a(n);

vector<int> case1(n);

vector<int> case2(n);

for (int i = 0; i < n; i++) {

cin >> a[i];

}

case2 = a;

for (int i = 1; i < n; i++) {

int mn = min(case2[i], case2[i - 1]);

case2[i - 1] -= mn;

case2[i] -= mn;

}

for (int i = 1; i < n; i++) {

if (!(case2[i] >= case2[i - 1])) {

cout << "NO" << endl;

return;

}

}

cout << "YES" << endl;

}



signed main() {

FAST;

#ifndef ONLINE_JUDGE

fileIO;

#endif

int t = 1;

cin >> t;

for (int i = 1; i <= t; i++) {

// cout<<"Case "<<i<<": ";

solve();

}



return 0;

}



Code 2:
/*



وَهُوَ مَعَكُمْ أَيْنَ مَا كُنْتُم

_       _                           _          _               _   _

/ \     | |                         | |        | |             | | (_)

/   \    | |         |FREE|          | |   ___  | |__     __ _  | |  _

/ / \ \   | |       |PALESTINE|   _   | |  / _ \ | '_ \   / _` | | | | |

/ __ __ \  | |____                | |__| | |  __/ | |_) | | (_| | | | | |

/_/     \_\ |______|                \____/   \___| |_.__/   \__,_| |_| |_|



*/



#include <bits/stdc++.h>

using namespace std;

#define all(v) v.begin(), v.end()



#define endl '\n'

#define int long long

void tracking(vector<int> v) {

for (int i = 0; i < v.size(); i++) {

cout << v[i] << " ";

}

cout << endl;

}

void Input(vector<int> &v) {

for (int &x : v) {

cin >> x;

}

}



#define posative(a) max(a, 0LL);

#define FAST                                                                   \

ios_base::sync_with_stdio(0);                                                \

cin.tie(nullptr);                                                            \

cout.tie(nullptr);

#define fileIO                                                                 \

freopen("input.txt", "r", stdin);                                            \

freopen("output.txt", "w", stdout)



//-----------------------------------------------------------------------------------------------------------------------------------

void solve() {

int n;

cin >> n;

vector<int> a(n);

for (int &x : a)

cin >> x;



for (int i = 0; i < n; i += 2) {

if (a[i] > a[i + 1]) {

cout << "NO\n";

return;

}

}

cout << "YES\n";

}

signed main() {

FAST;

#ifndef ONLINE_JUDGE

fileIO;

#endif

int t = 1;

cin >> t;

for (int i = 1; i <= t; i++) {

// cout<<"Case "<<i<<": ";

solve();

}



return 0;

}



Answer: 1