I have the same solution and this should work as the overall complexity turns out to be N^2 log N which works well under the time limit for max test.
Edit: The binary search might cause problems as that adds a extra log N factor. I just used a array to check whether an element existed or not, making it constant time lookup.
I hope it doesnât cause any problems! But, it will take 8-9 iterations for the worst case, so shouldnât be such a big addition to the complexity, right?
i did the same. but foolishly set all the elements of dp array to 1, which could have been done efficiently as well. so time was n*max(a[i]). though it gave 100, will it succeed?
Sorry for typo. I knew its 2.5*10^8, but it should work I guess, because one codeforces and ideone, it takes 0.6 seconds or so, to run. Hence if you guys had O(n^2) algorithm, and they keep the TL even 1 sec, it has huge chance of passing. Cheer up, otherwise you could personally request them this.
What? what? How did you get time for such heavy duty local testing of your code? And whats your expected score? did your computer work fine at the Delhi centre??