fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const int Mod=1e9+7;
  5. const ll INF = 10000000000000;
  6. const int N = 1e6+7;
  7.  
  8. void solve() {
  9. int n;
  10. cin >> n;
  11. vector<int> a(n);
  12. for(int i=0;i<n;i++) cin >> a[i];
  13. sort(a.begin(),a.end());
  14. cout << a[n/2] << '\n';
  15. }
  16.  
  17. int main(){
  18. ios::sync_with_stdio(false);
  19. cin.tie(nullptr);
  20.  
  21. int t;
  22. cin >> t;
  23. while (t--) solve();
  24.  
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0.01s 5284KB
stdin
5
2
1 2
3
1 1 2
3
1 2 3
5
3 1 2 2 3
10
10 2 5 2 7 9 2 5 10 7
stdout
2
1
2
2
7