본문 바로가기
알고리즘 & 자료구조/백준

백준 11568

by 신재권 2022. 1. 20.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main11568 {

	public static void main(String[] args) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int N = Integer.parseInt(br.readLine()); 
		int[] card = new int[N];
		int[] D = new int[N];
		
		StringTokenizer st = new StringTokenizer(br.readLine());
		for(int i=0; i<N; i++) {
			card[i] = Integer.parseInt(st.nextToken());
		}
		
		//LIS(가장 긴 증가하는 부분 수열) 
		//D[i] = max(D[i], D[j]+1)
		
		int ans = -1;
		for(int i=0; i<N; i++) {
			D[i] = 1;
			for(int j=0; j<i; j++) {
				if(card[i] > card[j]) {
					D[i] = Math.max(D[i], D[j]+1);
				}
			}
			ans = Math.max(ans, D[i]);
		}

		
		System.out.println(ans);

		
		
		
	}
	
	
	
}

 

'알고리즘 & 자료구조 > 백준' 카테고리의 다른 글

백준 1106  (0) 2022.01.22
백준 15989  (0) 2022.01.21
백준 10571  (0) 2022.01.19
백준 9764  (0) 2022.01.18
백준 9711  (0) 2022.01.17