C++ SIMPLE MIN-HEAP SOLUTION
Code\n\nclass Solution {\npublic:\n    vector<int> maxSubsequence(vector<int>& nums, int k) {\n        priority_queue<pair<int,int>,vector<pair<int,int>>,greate
# Code\n```\nclass Solution {\npublic:\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        int n=nums.size();\n        for(int i=0;i<n;i++){\n            if(pq.size()<k) pq.push({nums[i],i});\n            else if(pq.size()==k && pq.top().first<nums[i]){\n                pq.pop();\n                pq.push({nums[i],i});\n            } \n        }\n        vector<pair<int,int>> vec;\n        while(pq.size()>0){\n            int val=pq.top().first, idx=pq.top().second;\n            pq.pop();\n            vec.push_back({idx,val});\n        }\n        sort(vec.begin(),vec.end());\n        vector<int> ans;\n        for(int i=0;i<k;i++) ans.push_back(vec[i].second);\n        return ans;\n    }\n\n};\n```
['C++']