C++ Solution [Faster than 94.47%]
\nclass Solution {\npublic:\n    static bool comp(const pair<int,int> a,const pair<int,int> b){\n        return a.second<b.second;\n    }\n    vector<int> maxSu
```\nclass Solution {\npublic:\n    static bool comp(const pair<int,int> a,const pair<int,int> b){\n        return a.second<b.second;\n    }\n    vector<int> maxSubsequence(vector<int>& nums, int k) {\n        priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;\n        for(int i=0;i<nums.size();i++){\n            pq.push({nums[i],i});\n            if(pq.size()>k){\n                pq.pop();\n            }\n        }\n        \n        vector<pair<int,int>> v;\n        while(!pq.empty()){\n            int num=pq.top().first;\n            int pos=pq.top().second;\n            pq.pop();\n            v.push_back({num,pos});\n        }\n        vector<int> ans;\n        sort(v.begin(),v.end(),comp);\n        for(auto it:v){\n            ans.push_back(it.first);\n        }\n        return ans;\n    }\n};\n```
['C', 'Heap (Priority Queue)']