Hi everyone, im currently solving this problem. I dont know why if i test on my computer, the answer is right but when i submit, i get WA. I suspect its because of some memory issues, but i cant find any.
https://mirror.codeforces.com/contest/1712/submission/366889551
Heres the test
4 1 2 2 3 1000000000









Your solution works on this testcase in custom invocation.
I think it's likely due to the problem in initialization between testcases.
Yes, i have thought of it too, i have tried to initialize in main in this submission but nothing change
https://mirror.codeforces.com/contest/1712/submission/366889191
Oh, it seems that you managed to leak some specific testcase, but you altered it when calculating the answer (by sorting the array), so that testcase might not be correct.
Try this input. The answer should be $$$4$$$ and you're outputting $$$3$$$.
Oh crap, thank you so much!