### WayBig's blog

By WayBig, history, 11 months ago,

In today's ABC305, I used multisource BFS to solve problem E. But it is giving TLE. Can anyone please point out the mistake? Moreover, an almost similar question also happened to appear in Codechef STARTERS 93. And an almost similar code, written by me, got accepted in it.

Code
• +3

By WayBig, history, 12 months ago,

### Dear Codeforces,

I wonder why there are so much fewer contests in the upcoming 1 month. Earlier, Codeforces used to have at least 2 contests per week but I see there are hardly 3 contests in the next 1 month. Is the contest page not updated or there's some other issue or there's actually not many contests coming up?

Thank you.

• -20

By WayBig, history, 12 months ago,

I am facing Time Limit Exceeded in the problem Coin Combinations II of cses.

Code:

Full code

My approach: We define rec(x, r) as the number of ordered ways to make a sum x by using up to rth coin (0-indexing). Now we are iterating from the last coin. We can either take rth coin and add up rec(x — c[r], r) to our answer or we can not take the rth coin and simply add up rec(x, r-1) (the answer by taking up to (r-1)th coin). So we have:

dp[i][j] = dp[i - c[j]][j] + dp[i][j - 1]

We also do dp[i][j] %= MOD to prevent overflow.

What could be the possible reason for Time Limit Exceeded? Thank you.

UPD: One person in the comments told that it is because constraints on CSES are tight and that's why recursion might give a TLE on CSES. I think that answers the question.

UPD: This is the exact reason for the TLE

• +4