fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int casos;
  13. casos = Integer.parseInt(br.readLine());
  14. for(int c = 0; c<casos;c++) {
  15. int temp[] = new int[2];
  16. int N = Integer.parseInt(br.readLine()); //Linea 1 caso
  17. int maxi =-1; temp[0]= temp[1]=-1;
  18. StringTokenizer st = new StringTokenizer(br.readLine()); //Linea 2 caso
  19. for(int i = 0; st.hasMoreTokens();i++) {
  20. temp[i%2] = Integer.parseInt(st.nextToken());
  21. maxi = Math.max(Math.min(temp[i%2],temp[(i+1)%2]), maxi);
  22. }
  23. System.out.println(maxi);}}
  24.  
  25. }
Success #stdin #stdout 0.07s 54304KB
stdin
2
2
5 7
3
4 7 6
stdout
5
6