Codeforces and Polygon may be unavailable from May 23, 4:00 (UTC) to May 23, 7:00 (UTC) due to technical maintenance. ×

Need help in figuring out to how to fix TLE issue in my submission.

Revision en1, by CrypticTaiga, 2020-07-27 15:54:36

Problem — [problem:1315/B]

Submission — My Submission

I tried to solve the problem by taking the calculating the costs from all indexes starting from 0 upto n-1, and finally comparing the cost with the value of p. This is failing for large testcases and I get TLE. Can you help me figure out how to make the dp array to save precalculated costs for index i and then use to to calculate for the string of prefix i + 1. I tried but its not working correctly.

Thanks.

Tags #java8, #dp, #algorithms, #data structures

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English CrypticTaiga 2020-07-27 16:13:28 104
en2 English CrypticTaiga 2020-07-27 15:55:29 47
en1 English CrypticTaiga 2020-07-27 15:54:36 617 Initial revision (published)