Editorial for COCI '10 Contest 5 #5 Dvoniz
Submitting an official solution before solving the problem yourself is a bannable offence.
Let us freeze the middle of an interesting sequence in all possible ways. It can easily be noticed that if there exists a sequence of length
For each element, we first search for the longest sequence which starts with that element. To solve that problem, we process elements from right to left. Among all interesting sequences
When we move to the right, we decrease that maximum by
The above algorithm can easily be implemented with
Comments