Sort + Priority Queue | C++
\nclass Solution {\npublic:\n    int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n        int n = profits.size(), p = 0;\n 
```\nclass Solution {\npublic:\n    int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n        int n = profits.size(), p = 0;\n        vector<pair<int, int>> v;\n        for(int i=0; i<n; i++) v.push_back({capital[i], profits[i]});\n\n        sort(v.begin(), v.end());\n        priority_queue<pair<int, int>> pq;\n\n        for(int _=0; _<k; _++) {\n            while(p < n && v[p].first <= w) pq.push({v[p].second, v[p].first}), p++;\n            if(pq.size()) {\n                w += pq.top().first;\n                pq.pop();\n            }\n        }\n        return w;\n    }\n};\n```
['Greedy', 'Sorting', 'Heap (Priority Queue)', 'C++']