DP + Binary search C++ O(nlogn)
\nclass Solution {\npublic:\n    static bool comp(vector<int>& a, vector<int>& b){\n        return a[0] < b[0];\n    }\n    long long maxTaxiEarnings(int n, vec
```\nclass Solution {\npublic:\n    static bool comp(vector<int>& a, vector<int>& b){\n        return a[0] < b[0];\n    }\n    long long maxTaxiEarnings(int n, vector<vector<int>>& A) {\n        sort(A.begin(), A.end(), comp);\n        vector<long long> dp(A.size());\n        vector<int> t = A.back();\n        dp[A.size()-1] = t[1] -t[0] + t[2];\n        for(int i = A.size()-2; i >= 0; i--){\n            vector<int> t = {A[i][1], INT_MIN};\n            int j = upper_bound(A.begin() + i, A.end(), t) - A.begin();\n            dp[i] = max(dp[i+1], (long long)A[i][1] - A[i][0] + A[i][2] + (j < A.size() ? dp[j]: 0));\n        }\n        \n        return dp[0];        \n    }\n};\n```
[]