PAT (Top Level) Practice 1017 The Best Peak Shape (35 分) 题解

本文介绍了PAT题库中的一道题目,涉及找到最佳的峰值形状。通过从两个方向寻找最大上升子序列,将结果合并来解决。题目要求在给定有序序列中找到最长的峰值形状,如果存在多个,则选择最对称的。文章提供了输入输出规格及样例,并附带了解题代码。
摘要由CSDN通过智能技术生成

----

>我的GIS/CS学习笔记:https://github.com/yunwei37/ZJU-CS-GIS-ClassNotes
<一个浙江大学本科生的计算机、地理信息科学知识库 >
还有不少数据结构和算法相关的笔记以及pta题解哦x
----

PTA top level 练习里面的一道题目...挺简单的,就是读懂题目然后注意一下边界条件。

是浙江大学高级数据结构与算法课程的一个小作业啦

# 思路

就是两个最大上升子序列,从正反两个方向进行,然后把结果叠加到一起就好啦。不算注释的话30行代码...可以说非常少了x

In many research areas, one important target of analyzing data is to find the best "peak shape" out of a huge amount of raw data full of noises. A "peak shape" of length L is an ordered sequence of L numbers { D​1​​, ⋯, D​L​​ } satisfying that there exists an index i (1<i<L) such that D​1​​<⋯<D​i−1​​<D​i​​>D​i+1​​>⋯>D​L​​.

Now given N input numbers ordered by their indices, you may remove some of them to keep the rest of the numbers in a peak shape. The best peak shape is the longest sub-sequence that forms a peak shape. If there is a tie, then the most symmetric (mea

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值