simple binary search solution
```\nclass Solution {\npublic:\n    #define ll long long int\n    long long minimumMoney(vector>& transactions) {\n        ll l=0,r=1e14;\n        ll ans=1e18;\
```\nclass Solution {\npublic:\n    #define ll long long int\n    long long minimumMoney(vector<vector<int>>& transactions) {\n        ll l=0,r=1e14;\n        ll ans=1e18;\n        ll sum=0;\n        sort(begin(transactions),end(transactions));\n        for(auto &x:transactions){\n            x[1]=max(0ll,(ll)x[0]-x[1]);\n            sum+=x[1];\n        }\n        if(sum==0){\n            return transactions[transactions.size()-1][0];\n        }\n        while(l<=r){\n            ll mid=(l+r)/2;\n            bool check=false;\n            ll cur=mid;\n            for(auto p:transactions){\n                if(mid-sum<p[0]-p[1]){\n                    check=true;\n                    break;\n                }\n            }\n            if(check){\n                l=cur+1;\n            }\n            else{\n                r=cur-1;\n            }\n        }\n        return r+1;\n    }\n};
[]