fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int t, n;
  6. cin >> t;
  7. while (t--) {
  8. cin >> n;
  9. vector<int> a(n);
  10. for (int &x : a) cin >> x;
  11.  
  12. int min1 = INT_MAX, min2 = INT_MAX;
  13. for (int x : a) {
  14. if (x < min1) {
  15. min2 = min1;
  16. min1 = x;
  17. } else if (x > min1 && x < min2) {
  18. min2 = x;
  19. }
  20. }
  21.  
  22. if (min2 == INT_MAX) cout << "-1\n";
  23. else cout << min1 << " " << min2 << "\n";
  24. }
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0.01s 5292KB
stdin
2
10
5 6 7 8 9 10 1 2 3 4
5
1 1 1  1  1
stdout
1 2
-1