how to remove time limit exceeded [TLE] from this program? Newbie asking for help!!

above is the link of my solution to question NOMATCH Problem - CodeChef
Please give suggestion how to speed up my code. I am newbie to competitive programming.Any help would be appreciated.Thank You.

Update your solution link…

For solving you can follow the greedy strategy i.e. sort the input and take the difference between first and last…second and second last…and so on.

I looked at your solution for all submissions tab and the issue with your solution in most probably the merge sort algorithm you have implemented. Since c doesn’t have inbuilt sorting algorithm so may be either just learn a different language or may be try to optimise your sorting algorithm.Try to write in place merge sort, that may help idk. But it’s better if you just learn a new language.

The real problem is that you have not taken array elements as input and also your merge sort is not working properly.Otherwise your approach is fine.You should try to correct your merge sort or can also try a new language(for example C++) that has inbuilt sort function.

I have seen your latest submission of NOMATCH problem you have not taken elements of array as an input. Inspite of using mergesort you can use a predefined function sort in c++. It will be better if you use stl in C++14.This will help you a lot.

Have a look at the given links.

STL link

bits/stdc++.h