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

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

hello, my friends, I'm solving a DP problem on Cses and I got a time limit exceeded but I saw a solution for the problem using bottom-up technique but I got a time limit on top-down technique although we use the same approach

can someone explain why I get TLE ?

my code https://ideone.com/inIGo6

bottom-up solution https://ideone.com/Pp0EA5

Problem link https://cses.fi/problemset/task/1636

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

»
3 года назад, # |
Rev. 2   Проголосовать: нравится +1 Проголосовать: не нравится

Mostly, the time limit in the CSES set for DP is made just to accept iterative approach, as the recursive method is costly as compared to iterative, given the same constraints (See). Try making lesser operation in the recursive function or go for the iterative.

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

Please specify the problem you want to solve and the link to the problem.

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

It´s not your problem but it´s faster to use "const int mod" than "int mod"

  • »
    »
    6 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    You are right, I had the same problem but when I turned the variables to const int&, the runtime reduced to its half. So ridiculous