ZCO 2014 Smartphone

Why is my code not getting accepted even when i have tested all selfmade testcases to be running correctly

My code is at given link- link

When I opened your code I got a TLE. You are complicating it a little too much. There is a logic in this question which is actually very simple. The maximum profit will always be a multiple of one of the customers budget.

The problem is in your merge function.
You are arbitrarily declaring an array of 100 size. The constraints are lot higher.
Also change all your int’s to long long to avoid danger.
See here all same with the above changes implemented.

tomorrow is exam so you shall use one thing it will save your time.
Use algorithm.h it has various functions such as sort() it will sort your array and you won’t have to worry for sorting part.
int A[5]={7,6,4,8,1};

@asc4155 is right. You are overcomplicating it.
Here’s my code that fetched me 100 points https://ideone.com/wm4sDz

What’s wrong with my code (excluding the slow sorting algorithm)?

Yes , you are right , the problem is in the merge function because of size of the array being 100. That is because it is running correctly because when i give about input of size 10 - 20.