Advertisement
hkshakib

Untitled

Feb 2nd, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const ll mx =3e5+102;
  5. ll a[mx];
  6. int main ()
  7. {
  8. int t;
  9. cin>>t;
  10. while(t--)
  11. {
  12. int n;
  13. cin>>n;
  14. for(int i=0; i<n; i++)
  15. cin>>a[i];
  16. int j=0,l=0,r=n-1;
  17. while(l<n&&a[l]>=j)
  18. {
  19. j++;
  20. l++;
  21. }
  22. j=0;
  23. while(r>=0&&a[r]>=j)
  24. {
  25. j++;
  26. r--;
  27. }
  28. if(n==2&&a[0]==0&&a[1]==0)
  29. l=0,r=n;
  30. (l==n||r==-1||l-1>=r+1)?puts("Yes"):puts("No");
  31.  
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement