How did the solution get accepted by adding just this line ?

Правка en2, от Kar98k, 2019-06-21 15:21:30

https://codeforces.com/problemset/problem/498/B

For the above question, this was my TLE solution : 55865422 : time=1000ms

and this was my Accepted solution : [submission:55865596] : time=155ms

In TLE solution, i just added one line: if( dp[i][j] < (1e-12) ) dp[i][j]=0;

and it got accepted.

I am not able to understand that how this one line is able to reduce the time complexity ( and also by such huge margin ) as it is not involved in any of the loops.

P.S : i have added this line after looking that many of the Tle solutions got accepted after adding this line same as mine did.

Теги #2d-dp, time complexity, complexity optimization

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский Kar98k 2019-06-21 15:30:42 26 Tiny change: 'ime=1000ms\n\n and this ' -> 'ime=1000ms and this '
en2 Английский Kar98k 2019-06-21 15:21:30 131
en1 Английский Kar98k 2019-06-21 15:10:50 614 Initial revision (published)