fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. int T;
  7. cin >> T;
  8.  
  9. while (T--) {
  10. int N;
  11. cin >> N;
  12.  
  13. int dem[100005] = {};
  14.  
  15. for (int i = 0; i < N; i++) {
  16. int x;
  17. cin >> x;
  18. dem[x]++;
  19. }
  20.  
  21. int dientich = -1;
  22. int sl = 0;
  23.  
  24. for (int i = 1; i <= 1000; i++) {
  25. if (dem[i] >= 4) {
  26. if (i * i > dientich) {
  27. dientich = i * i;
  28. sl = dem[i] / 4;
  29. }
  30. }
  31. }
  32.  
  33. if (dientich == -1)
  34. cout << -1 << endl;
  35. else
  36. cout << dientich << " " << sl << endl;
  37. }
  38.  
  39.  
  40.  
  41.  
  42. return 0;
  43. }
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
Standard output is empty