Advertisement
ledkaa

Untitled

May 16th, 2023
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.List;
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6. public static void main(String[] args) {
  7. Scanner input = new Scanner(System.in);
  8. int n= input.nextInt();
  9. input.nextLine();
  10. String[] myList = input.nextLine().split(" ");
  11.  
  12. int maxCount=0;
  13. String jumps="";
  14.  
  15.  
  16. for (int i = 0; i < myList.length; i++) {
  17. int counter=0;
  18. int num=Integer.parseInt(myList[i]);
  19. for (int j =i+1; j <n ; j++) {
  20. int currentNum=Integer.parseInt(myList[j]);
  21. if (num < Integer.parseInt(myList[j])) {
  22. counter++;
  23. num=Integer.parseInt(myList[j]);
  24. }
  25.  
  26. }
  27. jumps+=counter+" ";
  28. if(counter>maxCount)
  29. {
  30. maxCount=counter;
  31. }
  32. }
  33. System.out.println(maxCount);
  34. System.out.println(jumps);
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement