Advertisement
Guest User

Za dime od oli <3

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