himank's blog

By himank, 10 years ago, In English

My code (C++) is having worst case complexity of 10^8 (precisely 9*10^7 )and time limit for the question is 3 sec. I am getting TLE, so what should be worst case complexity to pass the test cases.

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

| Write comment?
»
10 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Sorry, question is from ongoing codechef long contest.

  • »
    »
    10 years ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    In that case, try heavy optimization. Of course, if it's not a DP and you mean just that the complexity is like O(N2K) where N ≤ 103 and K ≤ 90, then there can be a big bad constant factor.

    Try running your code on your system and check how long it runs on some worst cases.

    • »
      »
      »
      10 years ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      I checked it on my system it was taking around 4 sec for worst case. But finally i corrected it and got it accepted. :) Thanks BTW.