Guest User

Untitled

a guest
Mar 17th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. Scanner sc = new Scanner(System.in);
  5. int[]d=new int[1001];
  6. int[]a=new int[1001];
  7. int n = sc.nextInt();
  8. for (int i=1;i<=n;i++) {
  9. a[i]=sc.nextInt();
  10. }
  11. int max = 0;
  12. for (int i=1;i<=n;i++) {
  13. d[i]=1;
  14. for(int j=1;j<i;j++) {
  15. if(a[i]<a[j] && d[i]<=d[j]) {
  16. d[i]=d[j]+1;
  17. }
  18. }
  19. }
  20. for (int i=1;i<=n;i++) {
  21. for(int j=1;j<=i;j++) {
  22. if(d[i]>max) {
  23. max=d[i];
  24. }
  25. }
  26. }
  27. System.out.println(max);
  28. sc.close();
  29. }
  30. }
Add Comment
Please, Sign In to add comment