practice_account's blog

By practice_account, history, 6 years ago, In English

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.

  • Vote: I like it
  • -13
  • Vote: I do not like it

»
6 years ago, hide # |
 
Vote: I like it +15 Vote: I do not like it

You needed fast io.

Added the two lines ios_base::sync_with_stdio(false); and cin.tie(NULL);

AC Submission: https://codeforces.me/contest/1221/submission/85249026

»
6 years ago, hide # |
 
Vote: I like it +4 Vote: I do not like it

You TLE because you aren't using fast input. Add this line to the beginning of your main and it easily AC's:

ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);