fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int temp[2];
  5.  
  6. int solve(){
  7. int N; cin>>N;
  8. int maxi =-1; temp[0]= temp[1]=-1;
  9. for(int i = 0; i<N;i++) { cin>>temp[i%2];
  10. maxi = max(min(temp[i%2],temp[(i+1)%2]), maxi);}
  11. return maxi;
  12. }
  13.  
  14. int main() {
  15. int cases; cin>>cases;
  16. while(cases--) cout<<solve()<<"\n";
  17. return 0;
  18. }
Success #stdin #stdout 0.01s 5280KB
stdin
2
2
5 7
3
4 7 6
stdout
5
6