Comments

I think you made some mistake when you print the answer, have a try on this data :

6 1 4
4 3 2 2 1 1

your code has output 4 numbers in the second line, while the correct case should be 3. By the way, I suggest you use > instead of >= in myfunc() , it seems that c++ requires strictly lower or bigger.

First time become blue in this round, feeling good ^_^ .