c++ solution using binary search not stl
\nclass Solution {\npublic:\n    static bool cmp(vector<int>&v1,vector<int>&v2)\n    {\n        return v1[1]<v2[1];\n    }\n    int maxTwoEvents(vector<vector<i
```\nclass Solution {\npublic:\n    static bool cmp(vector<int>&v1,vector<int>&v2)\n    {\n        return v1[1]<v2[1];\n    }\n    int maxTwoEvents(vector<vector<int>>&nums) \n    {\n        int n=nums.size();\n        // vector<int>dp(n+10,0);\n        sort(nums.begin(),nums.end(),cmp);\n        // dp[0]=nums[0][2];\n        int ans=nums[0][2];\n        for(int i=1;i<n;i++)\n        {\n            int s=nums[i][0];\n            int e=nums[i][1];\n            int cost=nums[i][2];\n            nums[i][2]=max(nums[i][2],nums[i-1][2]);\n            int l=0;\n            int r=i-1;\n            int index=-1;\n            while(l<=r)\n            {\n                int mid=(l+r)/2;\n                if(nums[mid][1]<s)\n                {\n                    index=mid;\n                    l=mid+1;\n                }\n                else\n                {\n                    r=mid-1;\n                }\n            }\n            if(index!=-1)\n            {\n                cost+=nums[index][2];\n            }\n            ans=max(ans,cost);\n        }\n       \n        return ans;\n    }\n};\n```
['C', 'Binary Tree', 'C++']