Roach00's blog

By Roach00, history, 5 years ago, In English

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

These are the two solutions :

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

https://mirror.codeforces.com/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?

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it