Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class A321 {
  4.     public static void main(String[] args) {
  5.         Scanner sc = new Scanner(System.in);
  6.         int N = sc.nextInt();
  7.         int[] array = new int[N];
  8.  
  9.         for (int i = 0; i < N; i++) {
  10.             array[i] = sc.nextInt();
  11.         }
  12.  
  13.         printLogestIncSubArr(array, array.length);
  14.     }
  15.  
  16.     public static void printLogestIncSubArr(int arr[], int n) {
  17.         int max = 1, len = 1;
  18.         for (int i = 1; i < n; i++) {
  19.             if (arr[i] >= arr[i - 1])
  20.                 len++;
  21.             else {
  22.                 if (max < len) {
  23.                     max = len;
  24.                 }
  25.                 len = 1;
  26.             }
  27.         }
  28.  
  29.         if (max < len) {
  30.             max = len;
  31.         }
  32.  
  33.         System.out.println(max);
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement