Solution in C++
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>& p, vector<int>& c) {\n        priority_queue<pair<int,int>> pq1;\n        priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq2;\n        for(int i=0;i<p.size();i++){\n            if(c[i]>w) pq2.push({c[i],p[i]});\n            else pq1.push({p[i],c[i]});\n        }\n        \n        while(k>0 && (!pq1.empty() || !pq2.empty())){\n            while(!pq2.empty() && pq2.top().first<=w){\n                pq1.push({pq2.top().second,pq2.top().first});\n                pq2.pop();\n            }\n            if(!pq1.empty()) {\n                w+=pq1.top().first;\n                pq1.pop();\n                k--;\n            } else return w;\n        }\n        return w;\n    }\n};\n```
['C++']