This is my solution. It was rejected by Codechef in the contest. Can anyone tell me the reason behind it.
Try running it on a testcase where T=1, N=10^5, K=3, and every element in the array is 10^5.
Your code is mostly correct, it fails for the following case :- 1
1 2 3 4 5
Happened to 90% of the people in the contest, it made me so sad that I left the contest
I think range of integer is under these conditions. Meanwhile I had tried to submit this code in ‘long’ datatype too but not get accepted.
I tested your solution just now, it fails for the case the I mentioned above , fix it and you’ll get AC
I should have taken this condition too. Nevertheless, it was my mistake and I accept it.
Why is this sol wrong? It works for the tc you given above.
Interesting: that fails on the same testcase as this one.