Pair of roses(wrong answer)

My code is working for the sample test case but is showing “wrong answer” for the main test case
https://ide.codingblocks.com/#/
https://hack.codingblocks.com/contests/c/262/696
i dont understand why it is failing

You have not saved your code in ide. Please share link of code after saving it.

https://ide.codingblocks.com/#/s/14852
here is the link

In your code you have not sorted the array, and you are assuming that it will be present after the ‘jth’ element to the end.
The second error is that you are including the jth element as well( which should not be done). e.g.
According to your logic it would give output as
1
3
4 3 1
6
then output will come as 3,3 because you have included jth element as well.
Your code can also work without sorting that I have modified
https://ide.codingblocks.com/#/s/15015

But, try to do it with sorting (for optimization).