WA when doing Dimension compression?

Revision en1, by MedoN11, 2015-07-11 02:25:10

Link to problem : http://codeforces.com/problemset/problem/543/A

DP solution with 501*501*501 memory (MLE but gives correct results when tested on PC) : http://ideone.com/edQhJr

DP solution with 2*501*501 memory ( dimension compressed) : gives WA on sample? : http://ideone.com/YNbwRO

Anyone has an idea why? Thanks.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English MedoN11 2015-07-11 02:25:10 366 Initial revision (published)