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.
| # | User | Rating |
|---|---|---|
| 1 | Benq | 3792 |
| 2 | VivaciousAubergine | 3647 |
| 3 | Kevin114514 | 3611 |
| 4 | jiangly | 3583 |
| 5 | strapple | 3515 |
| 6 | tourist | 3470 |
| 7 | dXqwq | 3436 |
| 8 | Radewoosh | 3415 |
| 9 | Otomachi_Una | 3413 |
| 10 | Um_nik | 3376 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 163 |
| 2 | adamant | 149 |
| 3 | Um_nik | 146 |
| 4 | Dominater069 | 143 |
| 5 | errorgorn | 141 |
| 6 | cry | 138 |
| 7 | Proof_by_QED | 135 |
| 7 | YuukiS | 135 |
| 9 | chromate00 | 134 |
| 10 | soullless | 132 |
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.
| Name |
|---|



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.