General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
97522500 Practice:
I_will_come_back
1443D - 16 C++17 (GCC 7-32) Accepted 31 ms 472 KB 2020-11-03 06:34:42 2020-11-03 06:34:42
→ Source
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word


#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
using namespace std;
#define Fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr);                 \
    cout.tie(nullptr)
#define f(i, n) for (long long int i = 0; i < n; i++)
#define ll long long int
#define fo(i, a, b) for (long long int i = a; i <= b; i++)
#define w(t)  \
    int t;    \
    cin >> t; \
    while (t--)
#define vi vector<int>
#define vl vector<long long int>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long int>>
#define mii map<int, int>
#define umii unordered_map<int,int>
#define mcl map<char,ll>
#define msl map<string,ll>
#define mll map<ll,ll>
#define umll unordered_map<ll,ll>
#define newl cout<<"\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll inf = 1e9 + 7;
const ll mod = 1e9+7;
#define MAX 300005


ll mini(ll a,ll b){
    if(a>=b)return b;
    return a;
}

ll maxi(ll a,ll b){
    if(a>=b)return a;
    return b;
}

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

vl find_factor_vector(ll n){
  vl F;
  F.pb(1),F.pb(n);
  fo(i,2,int(sqrt(n))){
      if(n%i==0){
        if(n/i == i)F.pb(i);
        else F.pb(i),F.pb(n/i);
      }
  }
  return F;
}

int main(){
    Fio;
    w(t){
        ll n;
        cin>>n;
        vl A(n+1);
        fo(i,1,n)cin>>A[i];
        ll i = 1;
        vl C(n+2,0);
        while(i<n){
            if(A[i+1]<=A[i]){
                C[1]+=A[i]-A[i+1];
                C[i+1]-=A[i]-A[i+1];
            }
            i++;
        }
        fo(i,1,n){
            C[i]+=C[i-1];
            A[i]-=C[i];
        }
        string ans = "YES";
        fo(i,2,n){
            if(A[i]<A[i-1] || A[i]<0 || A[1]<0){
                ans = "NO";
                break;
            }
        }
        cout<<ans;
        newl;
    }
    return 0;
}     
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details