Problem Solving/BOJ
[Silver 2] 11722번 가장 긴 감소하는 부분 수열
kmkunk
2022. 3. 29. 18:29
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
String[] a = br.readLine().split(" ");
int[] k = new int[n];
int ans = 0;
for(int i=0; i<n; i++) {
k[i] = 1;
for(int j=0; j<i; j++) {
if(Integer.parseInt(a[j])>Integer.parseInt(a[i]) && k[j]>=k[i]) {
k[i]++;
}
}
}
for(int i=0; i<n; i++) {
if(ans<k[i]) { ans = k[i]; }
}
System.out.println(ans);
}
}