c++
\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# Code\n\nclass Solution {\npublic:\n    int maxSelectedElements(vector<int>& A) {\n  
![image](https://assets.leetcode.com/users/images/3d254c96-8799-4a49-ae8e-910fd56de344_1719310303.3231466.png)\n\n\n![image](https://assets.leetcode.com/users/images/60a774ad-2332-4ee2-b494-0ee88ce28155_1718877687.385883.png)\n\n\n![image](https://assets.leetcode.com/users/images/031f8762-2651-4f41-a1fc-f86e04b85f2e_1718877663.1740532.png)\n\n\n![image](https://assets.leetcode.com/users/images/55943d7f-fe26-458b-9977-6c11d38d3d0f_1718870142.826415.png)\n\n\n![image](https://assets.leetcode.com/users/images/f334e5fc-4626-4135-9918-16cf455f3c3d_1718870118.4423225.png)\n\n\n![image](https://assets.leetcode.com/users/images/91693f9d-fbbc-44a4-a303-29867663b116_1718831645.462931.png)\n\n![image](https://assets.leetcode.com/users/images/e6c271b7-eff2-4aa2-bf4a-fa2c4ade4586_1718824904.1164255.png)\n\n\n![image](https://assets.leetcode.com/users/images/78c9747a-d0e5-4431-afb1-f870e5d680e4_1718627991.2954805.png)\n\n\n![image](https://assets.leetcode.com/users/images/92d12492-402a-4fdf-8561-d4e882e6058a_1718313035.960602.png)\n\n\n![image](https://assets.leetcode.com/users/images/8cb1aa6c-e5b7-445e-9fb2-aeda5a281054_1718036275.5639832.png)\n\n![image](https://assets.leetcode.com/users/images/12f90441-f805-43e3-8a5d-12d0d94b35bc_1718048364.222858.png)\n\n\n![Screenshot 2024-06-10 190417.png](https://assets.leetcode.com/users/images/9b41c3e4-3680-4438-a279-f31a913168ce_1718033846.6406753.png)\n\n\n![Screenshot 2024-06-10 210810.png](https://assets.leetcode.com/users/images/27e9c8a1-9d43-439a-9ed9-34884d5f458d_1718033905.835553.png)\n\n\n# Code\n```\nclass Solution {\npublic:\n    int maxSelectedElements(vector<int>& A) {\n        \n    }\n};\n```
['C']