SIMPLEST SOLUTION
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\nUse a pointer to test
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\nUse a pointer to test what you can push when you have capital equals w, because w always increases so p increase(sorted array).\n\n# Complexity\n- Time complexity: $$O(nlog)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n\tint findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n\t\tpriority_queue<int> heap;\t\t\n\t\tvector<int> id(profits.size(), 0); iota(id.begin(), id.end(), 0);\n\t\tsort(id.begin(), id.end(), [&](int x, int y) {\n\t\t\t\treturn capital[x] < capital[y];\n\t\t});\n\t\tint p = 0;\n\t\twhile (k--) {\n\t\t\twhile (p < capital.size() && capital[id[p]] <= w) heap.push(profits[id[p++]]);\n            if (heap.empty()) break;\n\t\t\tw += heap.top(); heap.pop();\n\t\t}\n\t\treturn w;\t\n\t}\n};\n\n```
['C++']