Educational Codeforces Round 81 E. Permutation Separation(dp+线段树优化)

NoSuchKey