对于最后两次选的数为 aia_iai/bib_ibi 的 444 种方案,在峰值个数相等时贪心选择 mx−mnmx-mnmx−mn 的最大值可过。 hack 数据: 输入:
7 8 2 7 5 8 7 1 4 9 6 7 6 5 1
正确输出:
3 8
错误输出:
3 7