Getting wrong answer on just changing one line which is very unexpected!!

Revision en2, by Roach00, 2019-06-24 20:09:17

This is the problem https://codeforces.me/contest/977/problem/F

These are the two solutions :

https://codeforces.me/contest/977/submission/55982217 (correct one)

https://codeforces.me/contest/977/submission/55982195 (wrong one)

The one line change is during input taking iteration where I am assigning value to dp[a[i]]. first I assigned dp[a[i]] = 1 , which gave wrong answer at large input(so can't debug by myself) but then when I changed it to dp[a[i]] = 0 , it made the solution accepted , but if you will see just next interation after the input taking iteration , it doesn't make sense to me because dp[a[i]] = max(dp[a[i]] , dp[a[i] — 1] + 1) should take care of the dp[a[i]] = 1. I don't know am I missing something?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Roach00 2019-06-24 20:09:17 2
en1 English Roach00 2019-06-24 01:39:37 823 Initial revision (published)