题意:n个士兵站成一排,求去掉最少的人数,使剩下的这排士兵的身高形成“峰形”分布,即求前面部分的LIS加上后面部分的LDS的最大值. 做法:分别求出LIS和LDS,枚举中点,求LIS+LDS的最大值.. 注意一点,有可能最中间的值重复,也有可能不重复,所以要考虑这两种情况:(假设中点为K) 1)不重复的情况,求LIS(K) + LDS(K+1)的最大值 2)重复的情况,这时K既包含在LIS当中,也包含在LDS中,计算了两次,最终结果要减掉1 复杂度:O(n^2) 代码: #include <io…