c++ using greedy
\nclass Solution {\npublic:\n    int minElements(vector<int>& nums, int limit, int goal) {\n        long long total=0;\n        for(int i=0;i<nums.size();i++){\
```\nclass Solution {\npublic:\n    int minElements(vector<int>& nums, int limit, int goal) {\n        long long total=0;\n        for(int i=0;i<nums.size();i++){\n            total+=nums[i];\n        }\n        long long count=0;\n        long long target=abs(goal-total);\n        while(target && limit){\n            count+=target/limit;\n                 target-=((target)/limit)*limit;\n                \n           limit--;\n        }\n        return count;\n    }\n};\n```
[]