WEIRD2 - EDITORIAL

That’s not n^2, read the editorial, see Quick Explanation point no. 2.
Happy Coding.

what if all the n elements are distinct??? I really don’t get it ??? #confused

If all elements are distinct, the inner loop will be executed only F[i] times, which is 1 in your test case. So, the Inner loop terminates after one iteration each time.

In my code CodeChef: Practical coding for everyone inner loop is running k times where k = no of distinct elements so in worst case (n times)
so the complexity is n^2. for the value of n=10e6 it should give TLE??? PLEASE HELP …

Or it could be one of his real fangirls appreciating his editorials? We never know :stuck_out_tongue:

Haha. (slow claps). Very funny.

but i lose 60 rating points by considering the problem is correct and many users get 100 points just by using brute force (that shouldn’t be work even for 30 points).