Xiangtan Invitation Contest 2017 - J Similar Subsequence(DP)
ForgivensequenceA=(a1,a2,...,an),asequenceS=(s1,s2,...,sn)hasshapeAifandonlyif:•si=min{si,si+1,...,sn}forallai=0;•si=max{si,si+1,...,sn}forallai=1.GivensequenceB=(b1,b2,...,bm),Bobowouldliketoknowthen