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 | tourist | 4009 |

2 | jiangly | 3839 |

3 | Radewoosh | 3646 |

4 | jqdai0815 | 3620 |

4 | Benq | 3620 |

6 | orzdevinwang | 3612 |

7 | Geothermal | 3569 |

8 | ecnerwala | 3494 |

9 | Um_nik | 3396 |

10 | gamegame | 3386 |

# | User | Contrib. |
---|---|---|

1 | Um_nik | 164 |

2 | -is-this-fft- | 160 |

2 | maomao90 | 160 |

4 | atcoder_official | 158 |

4 | cry | 158 |

4 | awoo | 158 |

7 | adamant | 155 |

8 | nor | 154 |

9 | TheScrasse | 153 |

10 | Dominater069 | 152 |

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.

↑

↓

Codeforces (c) Copyright 2010-2024 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Oct/04/2024 05:08:56 (j1).

Desktop version, switch to mobile version.

Supported by

User lists

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.

281369677

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

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

worked!!! thanks.

understood why !!]