require two heaps, max and min
\nclass Solution {\npublic:\n    struct compare {\n        bool operator()(pair<int ,int> p, pair<int ,int> q) {\n            return p.first>q.first;\n        }
```\nclass Solution {\npublic:\n    struct compare {\n        bool operator()(pair<int ,int> p, pair<int ,int> q) {\n            return p.first>q.first;\n        }\n    };\n    int findMaximizedCapital(int k, int w, vector<int>& p, vector<int>& c) {\n        priority_queue<pair<int,int>, vector<pair<int,int>>, compare> min_pq;\n        priority_queue<int> max_pq;\n        for(int i =0;i<c.size();i++)\n        {\n            min_pq.push({c[i],p[i]});\n        }\n        int i=0,n=c.size();\n       while(k--)\n       {\n           while(!min_pq.empty() && min_pq.top().first<=w)\n           {\n               max_pq.push(min_pq.top().second);\n               min_pq.pop();\n           }\n           \n           if(!max_pq.empty())\n           {\n               w+=max_pq.top();\n               max_pq.pop();\n           }\n       }\n        \n        \n        return w;\n    }\n};\n```
['C']