fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int t;
  6. cin >> t;
  7. while(t--){
  8. int n,x;
  9. cin >> n;
  10. vector<int> a;
  11. for(int i=0;i<n;i++){
  12. cin >> x;
  13. if(i == 0 || i % 2 == 0) a.push_back(x);
  14. }
  15. cout << *max_element(a.begin(),a.end()) << endl;
  16. }
  17. return 0;
  18. }
Success #stdin #stdout 0.01s 5276KB
stdin
4
1
6
3
1 3 2
5
4 7 4 2 9
7
3 1 4 1 5 9 2
stdout
6
2
9
5