[C++] Sort the Array | Greedy
\nclass Solution {\npublic:\n    long long minimumMoney(vector<vector<int>>& arr) {\n        sort(arr.begin(),arr.end(),[&](const auto& p, const auto& q){\n    
```\nclass Solution {\npublic:\n    long long minimumMoney(vector<vector<int>>& arr) {\n        sort(arr.begin(),arr.end(),[&](const auto& p, const auto& q){\n            int x = min(-p[0],-p[0]+p[1]-q[0]);\n            int y = min(-q[0],-q[0]+q[1]-p[0]);\n            return (x<y || (x==y && p[0]>q[0]));\n        });\n        long long ans=INT_MAX, t=0ll;\n        for(int i=0;i<arr.size();++i){\n            t -= (long long)arr[i][0];\n            ans = min(ans,t);\n            t += (long long)arr[i][1];\n        }\n        return -ans;\n    }\n};\n```
['Greedy', 'C', 'Sorting', 'C++']