Absolute sorting

Here is the link: https://www.codechef.com/problems/PEC002

My solution C++: https://www.codechef.com/viewsolution/13277225

My solution python: https://www.codechef.com/viewsolution/13277380

Please tell what’s wrong?

Your both approach is right. The problem is within the question or may be in test cases. So please don’t waste your time in this one and practice some other question.

You can verify this by similar question given at hackerearth

ADVISE: Try to solve only those questions which has been added by codechef contest. Since these questions are error free and they also provide editorial to cross check what mistake you have doing so!


Giving another advise, which I think should also benefit people-

If you get a WA/repeated WA for any Q, immediately check for presence of an AC solution in YOUR language. Like, for this problem, I can see not even a single AC solution, and I find it a sufficient indication of faulty test cases. (as @bansal1232 rightly stated)

Why I said in your language is because, sometimes the test cases may be correct, but given in wrong format (extra white-space, extra lines, &etc) and hence it may give AC in one language (eg-C++) and give some error in other (eg-Python)

Rest assured, your concept in the question was correct. Even I thought of the same thing (modifying sort function by giving 3rd argument/function). Nice job on that one dear.



Yes…I also once thought…

1 Like

Test cases are absolutely wrong