Блог пользователя devapriyanta

Автор devapriyanta, история, 4 дня назад, По-английски

281319592

I have given a solution is o(n*m*5) which should ideally be accepted, but giving TLE. Can anyone please help me the flaw in this code.

TIA.

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
4 дня назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

It might be due to the fact that the number of test case is less than equal to 10^5 and you have done memset(dp,-1,sizeof(dp)); in each iteration , ur size of dp is 1000 by 5 , therefore the worst case time complexity for your code would be 5 * 10^8 in a testcase , which might be why you are getting tle.

»
4 дня назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

281369677

have tried defining vector with size pertaining to each test case but still failing.

»
4 дня назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

use INT_MIN or something like that, for initialize dp vector.