C# Binary Search
csharp\npublic class Solution\n{\n    public record struct Job(int Difficulty, int Profit);\n\n    public int MaxProfitAssignment(int[] difficulty, int[] profit
```csharp\npublic class Solution\n{\n    public record struct Job(int Difficulty, int Profit);\n\n    public int MaxProfitAssignment(int[] difficulty, int[] profit, int[] worker)\n    {\n        var max = int.MinValue;\n\n        var jobs = difficulty\n            .Zip(profit, (d, p) => new Job(d, p))\n            .OrderBy(j => j.Difficulty)\n            .ThenByDescending(j => j.Profit)\n            .Select(j => j with { Profit = max = Math.Max(max, j.Profit) })\n            .ToList();\n\n        return worker.Sum(skill =>\n        {\n            var index = jobs.BinarySearch(job => job.Difficulty > skill);\n            return jobs.ElementAtOrDefault(index - 1).Profit;\n        });\n    }\n}\n\npublic static class Extensions\n{\n    public static int BinarySearch<T>(this IList<T> list, Predicate<T> predicate)\n    {\n        var left = 0;\n        var right = list.Count;\n\n        while (left < right)\n        {\n            var mid = left + (right - left) / 2;\n\n            if (predicate(list[mid]))\n                right = mid;\n            else\n                left = mid + 1;\n        }\n\n        return left;\n    }\n}\n```
['Binary Search', 'C#']