Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Jump {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int size = Integer.parseInt(scanner.nextLine());
- String[] arrayString = scanner.nextLine().split(" ");
- int[] arrayOne = new int[size];
- int[] list = new int[size];
- for (int i = 0; i < size; i++) {
- arrayOne[i] = Integer.parseInt(arrayString[i]);
- }
- int counter = 0;
- for (int i = 0; i < size; i++) {
- for (int j = i + 1; j < size; j++) {
- if (arrayOne[i] < arrayOne[j] && arrayOne[j] > arrayOne[j - 1]) {
- arrayOne[i] = arrayOne[j];
- counter++;
- }
- }
- list[i] = counter;
- counter = 0;
- }
- int max = list[0];
- for (int element : list) {
- max = Math.max(max, element);
- }
- System.out.println(max);
- for (int x : list) {
- System.out.print(x + " ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement