chari407's blog

By chari407, history, 7 years ago, In English

This is my submission for Mollys Chemicals. Can someone tell me why it times out ? I calculated the Time complexity as follows — please correct me if I am wrong. 1. The preProcess function would work in O(46 log(46)). 2. The prefix sum computation takes O(n); 3. The subarray generation part (in the while loop) takes O(n^2 * log(46)) . (Because the set size would atmost be 46).

So adding them, O(46 log(46)) + O(n) + O(n^2 * log(46)) and with the constraint over n as 10^5, 46*5 + 10^5 + (10^10)*5.

Assuming 10^9 operations per second, the time limit given for the problem is 2.5 secs which means *2.5 * 10^9 operations can be allowed. Then why does my solution give TLE?

Please help me.

  • Vote: I like it
  • -7
  • Vote: I do not like it

| Write comment?
»
7 years ago, # |
  Vote: I like it +6 Vote: I do not like it

No, it means 2.5 * 10^9 operations are allowed

»
7 years ago, # |
  Vote: I like it +20 Vote: I do not like it

5*(10^10) is quite larger than 2.5*(10^9)