#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ull unsigned LL
#define db double
#define ldb long double
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)(x).size()
#define complete_unique(x) (x).erase(unique(all(x)),(x).end());
#define fr(x) freopen(x,"r",stdin);
#define fw(x) freopen(x,"w",stdout);
#define mst(x,a) memset(x,a,sizeof(x));
#define lowbit(x) ((x) & (-(x)))
#define ex0 exit(0);
#define IOS ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define inf 0x3f3f3f3f
#define yes std::cout << "Yes\n"
#define no std::cout << "No\n"
//#pragma GCC optimize(2) // if CE please delete
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };
const int base1 = 131;
const int base2 = 13331;
const int mod1 = 1e9 + 7;
const int mod2 = 1e9 + 9;
typedef pair<int, int> hashv;
hashv operator + (hashv a, hashv b) {
int c1 = a.fi + b.fi, c2 = a.se + b.se;
if (c1 >= mod1) c1 -= mod1;
if (c2 >= mod2) c2 -= mod2;
return mp(c1, c2);
}
hashv operator - (hashv a, hashv b) {
int c1 = a.fi - b.fi, c2 = a.se - b.se;
if (c1 < 0) c1 = c1 + mod1;
if (c2 < 0) c2 = c2 + mod2;
return mp(c1, c2);
}
hashv operator * (hashv a, hashv b) {
return mp(1ll * a.fi * b.fi % mod1, 1ll * a.second * b.second % mod2);
}
template <typename T>
inline T qpow(T a, int b, const int mod = 1e9 + 7) //quick_pow
{
T res = 1;
while (b)
{
if (b & 1) res = (res * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
return res;
}
LL gcd(LL a, LL b)
{
return b == 0 ? a : gcd(b, a % b);
}
inline char gc() {
static char buf[1000000], * p1 = buf, * p2 = buf;
return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2) ? EOF : *p1++;
}
template <typename T>
inline T read()
{
T x = 0, flag = 1;
char c = gc();
while (c < '0' || c > '9')
{
if (c == '-') flag = -1;
c = gc();
}
while (c >= '0' && c <= '9')
{
x = (x << 1) + (x << 3) + (c ^ 48);
c = gc();
}
return x * flag;
}
template <typename T>
inline void pr(T x)
{
if (x < 0)
{
putchar('-');
x = -x;
}
if (x > 9) pr(x / 10);
putchar(x % 10 + '0');
}
const int N = 2E6 + 10;
const int M = 4e6 + 10;
int a[N], d[N];
int n, m, k;
int main()
{
IOS;
int t;
cin >> t;
while (t--) {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
d[i] = a[i] - a[i - 1];
}
LL s = 0;
if (d[1]) s += d[1];
for (int i = 2; i <= n; i++) {
if (d[i] < 0) s += d[i];
}
if (s < 0) no;
else yes;
}
return 0;
}
1343C - Alternating Subsequence | 1325A - EhAb AnD gCd |
746A - Compote | 318A - Even Odds |
550B - Preparing Olympiad | 939B - Hamster Farm |
732A - Buy a Shovel | 1220C - Substring Game in the Lesson |
452A - Eevee | 1647B - Madoka and the Elegant Gift |
1408A - Circle Coloring | 766B - Mahmoud and a Triangle |
1618C - Paint the Array | 469A - I Wanna Be the Guy |
1294A - Collecting Coins | 1227A - Math Problem |
349A - Cinema Line | 47A - Triangular numbers |
1516B - AGAGA XOOORRR | 1515A - Phoenix and Gold |
1515B - Phoenix and Puzzle | 155A - I_love_username |
49A - Sleuth | 1541A - Pretty Permutations |
1632C - Strange Test | 673A - Bear and Game |
276A - Lunch Rush | 1205A - Almost Equal |
1020B - Badge | 1353A - Most Unstable Array |