[c++] Binary Search TLE
I see lots of solution passed  using binary serach. I got TLE using binary serach wondering why  ?\n\n\nclass Solution {\npublic:\n    int minimumEffort(vector<
I see lots of solution passed  using binary serach. I got TLE using binary serach wondering why  ?\n\n```\nclass Solution {\npublic:\n    int minimumEffort(vector<vector<int>>& tasks) {\n        long long lo = 0, hi = 0;\n        for (auto task : tasks) lo += task[0], hi += task[1];\n        sort(tasks.begin(), tasks.end(), [](auto a , auto b) {\n            if (a[1] - a[0] != b[1]- b[0]) return a[1] - a[0] > b[1] - b[0];\n            return a[1] > b[1];\n            \n        });\n       \n        //for (auto task : tasks) cout << task[0]<<":"<<task[1]<<" "; cout <<"\\n";\n        auto isValid = [](long long  energy, vector<vector<int>> tks) {\n            //cout << energy<<":: \\t";\n            int mini = tks[0][1], maxi = tks[0][0];\n            int idx = 0;\n          for (auto task : tks) {\n              if (task[1] <= energy) energy -= task[0];\n                else \n                    return false;\n              if (tks[0][0] == task[0]) mini = min (mini, task[1]);\n              idx++;\n          }\n          return true;\n        };\n        while (lo < hi) {\n            long long mid = (lo + hi)/2;\n            //cout << lo << " "<<mid <<" "<<hi<<"\\t"; \n            if (isValid(mid, tasks)) hi = mid;\n            else lo = mid + 1;\n            //cout << lo << " "<<mid <<" "<<hi<<"\\n"; \n        }\n        return lo;\n    }\n};\n```\n\nHelp will be appericiated. I spend lot of time debugging it but didn\'t find anything usefull
['Binary Tree']