Advertisement
Guest User

Untitled

a guest
Nov 21st, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class LDS {
  4.  
  5. private static int najdolgaOpagackaSekvenca(int[] a) {
  6. int temp=1;
  7. int najdolga=1;
  8. for (int i=1;i<a.length;i++)
  9. {
  10. if (a[i]<=a[i-1]) temp++;
  11. else
  12. {
  13. if(najdolga<temp) najdolga=temp;
  14. temp=1;
  15. }
  16. }
  17. return najdolga;
  18. }
  19.  
  20. public static void main(String[] args) {
  21. Scanner stdin = new Scanner(System.in);
  22.  
  23. int n = stdin.nextInt();
  24. int a[] = new int[n];
  25. for (int i = 0; i < a.length; i++) {
  26. a[i] = stdin.nextInt();
  27. }
  28. System.out.println(najdolgaOpagackaSekvenca(a));
  29. }
  30.  
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement