Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.lang.*;
- import java.io.*;
- public class Main
- {
- public static void main (String[] args) throws java.lang.Exception
- {
- Scanner sc=new Scanner(System.in);
- int n=sc.nextInt();
- int[] arr=new int[n];
- for(int i=0;i<n;i++)
- {
- arr[i]=sc.nextInt();
- }
- int[] dp=new int[n];
- for(int i=0;i<n;i++) dp[i]=1;
- int lis=1;
- for(int j=1;j<n;j++)
- {
- for(int i=0;i<j;i++)
- {
- if(arr[i]<arr[j])
- {
- if(dp[i]+1>dp[j])
- {
- dp[j]=1+dp[i];
- }
- }
- }
- if(dp[j]>lis)
- {
- lis=dp[j];
- }
- }
- System.out.println(lis);
- return ;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement