IT/알고리즘

[백준] 가장 긴 증가하는 부분 수열

남갯 2024. 10. 28. 22:11
SMALL

https://www.acmicpc.net/problem/11053

 

fun main() = with(Scanner(System.`in`)) {
    val count = nextInt()
    val array: Array<Int> = Array(count) { 0 }
    for(i in 0 until count){
        array[i] = nextInt()
    }
    val dp : Array<Int> = Array(count) { 1 }
    for(i in 1 until count){
        for(j in 0 until i){
            if(array[i] > array[j]){
                dp[i] = max(dp[i], dp[j] + 1)
            }
        }
    }

    println(dp.max())
}
LIST