complete 12015.kt 12738.kt 14626.kt 33985.kt 34029.kt 34060.kt 9252.py
This commit is contained in:
28
storage/zeta/kt/completed/12015.kt
Normal file
28
storage/zeta/kt/completed/12015.kt
Normal file
@@ -0,0 +1,28 @@
|
||||
fun getLengthLIS(arr: List<Int>): Int {
|
||||
val lisProps = mutableListOf<Int>()
|
||||
|
||||
arr.forEach {
|
||||
val x = lisProps.binarySearch(it).let { it ->
|
||||
if (it < 0) {
|
||||
-(it + 1)
|
||||
} else {
|
||||
it
|
||||
}
|
||||
}
|
||||
if (x == lisProps.size) {
|
||||
lisProps.add(it)
|
||||
} else {
|
||||
lisProps[x] = it
|
||||
}
|
||||
}
|
||||
|
||||
return lisProps.size
|
||||
}
|
||||
|
||||
|
||||
fun main() {
|
||||
readln()
|
||||
val arr = readln().split(' ').map { it.toInt() }
|
||||
|
||||
println(getLengthLIS(arr))
|
||||
}
|
||||
Reference in New Issue
Block a user