The slowness comes from the searchsort algorithm you've chosen. It's \$O(N^2)\$ and you can do better by using for examplea faster sort algorithm, such as merge sort or quicksort. Once you do that, the solution shouldwill pass with flying colors.
You could simplify the loop that checks the maximum difference by initializing unfairness to the diff of the first interval:
int unfairness = list[set] - list[0]; And then start the loop from 1, and simplify:
for (int x = 1; x < N - set; x++) { int diff = list[x + set] - list[x]; if (diff < unfairness) { unfairness = diff; } } Also, it would be good to put this code in a separate function. It's good to have many short functions that do one thing, than one long function that does many things.
Instead of initializing i at the top of the function, it would be better to do that inside the for-loop where you use it, just like you did for other loops.
I recommend to avoid using l as a variable name, because on some displays and fonts it's too hard to distinguish from 1 or I.