As the next DP problem from Codeforces, solve "Consecutive Subsequence". This problem shows how the same four-step DP pattern works even when the values in the array are large.
You are given a sequence a1,a2,…,an. find a subsequence (delete some elements, but you must keep the order) such that consecutive elements in the subsequence differ by exactly one. for indices of any subsequence i1,i2,…,ik you want aij+1=aij+1 Every j.
Among all such subsequences, you want the one with maximum length. You have to output the maximum length and the indices of the subsequence with the maximum length.
Constraints: 1≤n≤2⋅105 1≤a[i]≤109