AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Code


# Code
```kotlin []
import java.util.PriorityQueue
import kotlin.math.min

class Solution {
    fun maxSubsequence(nums: IntArray, k: Int): IntArray {
        val q = PriorityQueue<Int>()
        val result = ArrayList<Int>()
        for(num in nums){
            if(result.size < k){
                result.add(num)
                q.add(num)
            }else if(num > q.first()){
                result.remove(q.remove())
                q.add(num)
                result.add(num)
            }
        }
        return result.toIntArray()
    }
}
```
['Kotlin']