fork download
  1. # your code goes here
  2.  
  3.  
  4. def totalFriends(l, n):
  5. for i in range(n):
  6. if len(l[:i]) < l[i]:
  7. return i
  8. return i + 1
  9.  
  10. if __name__ == "__main__":
  11. for _ in range(int(input().strip())):
  12. n = int(input().strip())
  13. arr = list(map(int, input().strip().split(' ')))
  14. l = sorted(arr)
  15. print(totalFriends(l, n))
Success #stdin #stdout 0.02s 9156KB
stdin
3
2
0 0
6
3 1 0 0 5 5
3
1 2 3
stdout
2
4
0