RANKLIST pls determine on what input will I get WA

on the problem RANKLIST (http://www.codechef.com/FEB15/problems/RANKLIST/) I have made a code that works for the sample input and some self-identified input. But I get WA on the submission, will you determine on what testcases and why will my code receive WA?

http://www.codechef.com/viewsolution/6292396 ← here is my solution.

Can u explain your logic ?

i think you didnt get the question correctly.
Your code is wrong.

for test case.
10 38 your code gives 6 as o/p.
Correct ans is 2.

your code fails for following test cases:
(3,4)-{1,1,2} correct ans is 1
(4,5)-{1,1,1,2} correct ans is 2
(4,6)-{1,1,2,2} correct ans is 2
(4,7)-{1,1,2,3} correct ans is 1
(4,8)-{1,2,2,3} correct ans is 1
first try these test cases.your approach is correct but u have to find minimum number of operations required.

can you explain it to me then, how did it become 2?
38 should be a sum of a rank list… can you give me the sequence of rank list that has a sum of 38 and the minimum moves that can transform it to an ideal rank list is only 2

for test case 10 38 the sequence would be {1,1,1,2,3,4,5,6,7,8} so u need to change 1->9 & 1->10 so ans is 2

"(3,3)-{1,1,2} correct ans is 1 "

I know get it that it 1 is the answer, but on the problem, look at the sample input for 3 3, the output is 2… and there’s an explanation…

Example case 4.
Only possible rank list is {1 1 1}, You can convert it into an ideal rank list by changing a 1 to 2 and another 1 to 3 i.e. {1, 2, 3}, hence you need two operations.

this was not pointed out. I think I based my code on the sample input. my bad

sorry for inconvenience its (3,4) not (3,3) i have changed it now

OH. That was my mistake, I failed at knowing that the ideal rank list can be considered ideal even if its not sorted. Thanks, this is what I need I guess.

I do not get what’s wrong…
all my test cases are passed, still not accepting the code.
Can someone help me out with it ? (if there are any corner points plz tell)…
I have taken care of the min. no. of operations in my code:
[1]: http://codechef.com/viewsolution/6262852

I don´t know where is wrong. http://www.codechef.com/viewplaintext/6299775

@dark_energy , i think you are printing one extra line…