Editorial for Another Contest 8 Problem 5 - U-Turn Finesse

Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

If you have the primitive of "count the number of strictly increasing subsequences ending at a certain index", then you can solve this problem by reversing the original array and then multiplying results accordingly - to solve the primitive, you use a segment tree on values to optimize the DP from \mathcal{O}(N^2) to \mathcal{O}(N \log N).


There are no comments at the moment.