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