fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main () {
  4. int t = 1; cin >> t;
  5. while (t--) {
  6. int n; cin >> n;
  7. int a[n];
  8. for (int i = 0; i < n; i++) {
  9. cin >> a[i];
  10. }
  11. int ans = 0;
  12. sort(a, a + n);
  13. for (int i = 0 ; i < n; i++) {
  14. int x = -a[i];
  15. int MEX = 0;
  16. for (int j = 0; j < n; j++) {
  17. if (a[j] + x == MEX) {
  18. MEX++;
  19. }
  20. }
  21. ans = max(ans, MEX);
  22. }
  23. cout << ans << '\n';
  24. }
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 1.22s 5316KB
stdin
Standard input is empty
stdout
10