NOTE/BAEKJOON
11053 가장 긴 증가하는 부분
m-inz
2022. 3. 21. 21:50
import java.io.IOException;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;
public class main {
static int[] arr;
static int[] dp;
static int N;
static int count=0;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
N = Integer.parseInt(br.readLine());
arr = new int[N+1];
dp = new int[N+1];
StringTokenizer st = new StringTokenizer(br.readLine()," ");
for(int i=1; i<=N; i++) {
arr[i]=Integer.parseInt(st.nextToken());
}
dp[1]=1;
for(int i=2; i<=N; i++) {
dp[i]=1;
for(int j=1;j<i;j++) {
if(arr[i]>arr[j]) {
dp[i]=Math.max(dp[i],dp[j]+1);
}
}
}
int max=Integer.MIN_VALUE;
for(int i=1;i<=N;i++) {
max = Math.max(dp[i],max);
}
bw.write(max+"\n");
bw.flush();
bw.close();
}
}
LIS라고 해서,, 그냥 바로 풀이봤다 더 완벽히 이해해볼게요,,