C++ Solution | |  Greedy approach
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n         int n = profits.size();\n    vector<pair<int, int>> projects(n);\n    for (int i = 0; i < n; i++) {\n        projects[i] = {capital[i], profits[i]};\n    }\n    sort(projects.begin(), projects.end());\n\n    int idx = 0;\n    priority_queue<int> pq;\n    for (int i = 0; i < k; i++) {\n        while (idx < n && projects[idx].first <= w) {\n            pq.push(projects[idx].second);\n            idx++;\n        }\n        if (pq.empty()) {\n            break;\n        }\n        w += pq.top();\n        pq.pop();\n    }\n    return w;\n        \n    }\n};\n```
['C++']