Untitled
unknown
plain_text
2 months ago
906 B
2
Indexable
#include <bits/stdc++.h> using namespace std; void File() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } void solve() { int n;cin>>n; vector<int>a(n); for(auto &x:a)cin>>x; int lst=a[n-1]; bool f=1; for(int i=n-2;i>=0;i--){ if(a[i]==lst) a[i]=a[i]-2; else if(a[i]>lst){ if((a[i]-lst)%2==0) a[i]-=((a[i]-lst-2)+3); else a[i]-=(a[i]-lst+1); } lst=a[i]; if(a[i]<=0){ f=0; break; } } cout<<(f?"YES\n":"NO\n"); } signed main() { File(); int t = 1; cin >> t; for (int i = 0; i < t; ++i) { // cout << "Case " << i + 1 << ": "; solve(); } }
Editor is loading...
Leave a Comment