Short & Simple Binary Search(JAVA)
\npublic int maxProfitAssignment(int[] difficulty, int[] profit, int[] worker) {\n        int n = difficulty.length;\n        List<int[]> list = new ArrayList<>
```\npublic int maxProfitAssignment(int[] difficulty, int[] profit, int[] worker) {\n        int n = difficulty.length;\n        List<int[]> list = new ArrayList<>();\n        for(int i=0;i<n;i++) {\n            list.add(new int[]{difficulty[i],profit[i]});\n        }\n        list.sort((a,b)->(a[0]-b[0]!=0?a[0]-b[0]:b[1]-a[1]));\n        int[] max = new int[n];\n        max[0]=list.get(0)[1];// Maximum Value till a given index.\n        for (int i=1;i<n;i++) {\n            max[i]=Math.max(list.get(i)[1],max[i-1]); \n        }\n        int ans=0;\n        for(int w: worker) {\n            int res = bs(w,list);\n            ans+=res==-1?0:max[res];\n        }\n        return ans;\n    }\n\t// Smallest index which is less than or equal to the given target.\n    private int bs(int target,List<int[]> list) {\n        int lo = 0;\n        int hi = list.size()-1;\n        if(target>=list.get(hi)[0]) {\n            return hi;\n        }\n        int ans = -1;\n        while (lo<hi) {\n            int mid = (lo)+(hi-lo)/2;\n            int val = list.get(mid)[0];\n            if(target>=val) {\n                ans=mid;\n                lo=mid+1;\n            } else {\n                hi=mid;\n            }\n        }\n        return ans;\n    }\n```
[]