fork download
  1. import sys
  2. input = sys.stdin.readline
  3. def solve():
  4. t = int(input())
  5. res = []
  6. for _ in range(t):
  7. n = int(input())
  8. a = list(map(int, input().split()))
  9. rem = 0
  10. possible = True
  11. for i in range(n):
  12. total = a[i] + rem
  13. required = i + 1
  14. if total < required:
  15. possible = False
  16. break
  17. else:
  18. rem = total - required
  19. if possible:
  20. res.append("YES")
  21. else:
  22. res.append("NO")
  23. for i in res:
  24. print(i)
  25. solve()
  26.  
Success #stdin #stdout 0.08s 14084KB
stdin
7
3
1 2 3
3
1 1 2
3
10 1 1
3
2 2 2
4
1 4 2 2
5
8 2 8 1 8
4
1 1 3 5
stdout
YES
NO
YES
YES
NO
YES
NO