1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
 
public class Main { 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] ar = new int[n+1];
        int[] dp = new int[n+1];
        for(int i=1;i<=n;i++){
            ar[i] = sc.nextInt();
//            System.out.print(ar[i]+" ");
        }
        
        for(int i=1;i<=n;i++){
            dp[i]=1;
            for(int j=0;j<i;j++){
                if(ar[i]>ar[j]&&dp[j]+1>dp[i]){
                    dp[i] = dp[j]+1;
                }
            }
        }
        int max = 0;
        for(int i=0;i<=n;i++){
            max = (dp[i]>max)?dp[i]:max;
        }
        System.out.println(max);        
    }
}
cs


'알고리즘' 카테고리의 다른 글

[2096번] 내려가기  (0) 2017.08.13
[11729번] 하노이 탑 이동 순서  (0) 2017.08.13
[9084번] 동전  (0) 2017.08.13
[5598번] 카이사르 암호  (0) 2017.08.13
[2616번] 소형기관차  (0) 2017.08.13

+ Recent posts