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 arr[][]={{1,3,2},{5,3,1},{1,2,3}};
  13. int count = 0;
  14. for(int i=0;i<arr.length;i++) {
  15. count ++;
  16. int len = arr[i].length;
  17. //System.out.println("len : "+len);
  18. int maxHeight = arr[i][len-1];
  19. for(int j=len-1;j>=0;j--) {
  20. if(maxHeight<arr[i][j]) {
  21. count++;
  22. maxHeight = arr[i][j];
  23. }
  24. }
  25. }
  26. System.out.println(count);
  27.  
  28. }
  29. }
Success #stdin #stdout 0.05s 4386816KB
stdin
Standard input is empty
stdout
6