Question — 1221D - Make The Fence Great Again My submission — 85248917 I have written a O(N) dp solution still it does not pass the 17th testcase. I have seen the editorial which also has a O(N) solution. Can anyone please tell me where am I doing the extra work here.








You needed fast io.
Added the two lines
ios_base::sync_with_stdio(false);andcin.tie(NULL);AC Submission: https://codeforces.me/contest/1221/submission/85249026
Oh nice.Thanks So is there any harm if I add these lines always in my code for any question. I have never used fast io?
Yeah, there's no harm in including it so you might as well. In case you're curious why it causes a speedup, you can read this.
Thanks! Appriciate your effort
You TLE because you aren't using fast input. Add this line to the beginning of your main and it easily AC's: