动态规划找最长上升子序列,正反遍历一遍序列即可~

#include<bits/stdc++.h>
using namespace std;
const int maxn=;
int N;
int a[maxn];
int l[maxn];
int r[maxn];
int main () {
scanf ("%d",&N);
for (int i=;i<N;i++)
scanf ("%d",&a[i]);
int maxLength=;
int maxIndex;
int maxValue;
int mincha;
for (int i=;i<N;i++) {
for (int j=i-;j>=;j--)
if (a[j]<a[i]) l[i]=max(l[i],l[j]+);
}
for (int i=N-;i>=;i--) {
for (int j=i+;j<N;j++)
if (a[j]<a[i]) r[i]=max(r[i],r[j]+);
}
for (int i=;i<N;i++) {
if (l[i]==||r[i]==) continue;
int len=l[i]+r[i]+;
if (len>maxLength) {
maxLength=len;
maxIndex=i;
mincha=abs(l[i]-r[i]);
}
else if (len==maxLength&&abs(l[i]-r[i])<mincha) {
maxIndex=i;
mincha=abs(l[i]-r[i]);
}
}
if (maxLength==) printf ("No peak shape");
else printf ("%d %d %d",maxLength,maxIndex+,a[maxIndex]);
return ;
}

PAT T1017 The Best Peak Shape的更多相关文章

  1. jellyfish K-mer analysis and genome size estimate

    http://www.cbcb.umd.edu/software/jellyfish/   http://www.genome.umd.edu/jellyfish.html https://githu ...

  2. 1031. Hello World for U (20) PAT

    题目:http://pat.zju.edu.cn/contests/pat-a-practise/1031 分析: 简单题,调整数组的输出次序就可以了. 输入数组长度为len.n1 = n3 = (l ...

  3. PAT (Advanced Level) Practice 1031 Hello World for U (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1031 Hello World for U (20 分) 凌宸1642 题目描述: Given any string of N (≥5) ...

  4. (论文笔记Arxiv2021)Walk in the Cloud: Learning Curves for Point Clouds Shape Analysis

    目录 摘要 1.引言 2.相关工作 3.方法 3.1局部特征聚合的再思考 3.2 曲线分组 3.3 曲线聚合和CurveNet 4.实验 4.1 应用细节 4.2 基准 4.3 消融研究 5.总结 W ...

  5. OpenCASCADE Shape Location

    OpenCASCADE Shape Location eryar@163.com Abstract. The TopLoc package of OpenCASCADE gives resources ...

  6. Drawable实战解析:Android XML shape 标签使用详解(apk瘦身,减少内存好帮手)

    Android XML shape 标签使用详解   一个android开发者肯定懂得使用 xml 定义一个 Drawable,比如定义一个 rect 或者 circle 作为一个 View 的背景. ...

  7. 《转载》PAT 习题

    博客出处:http://blog.csdn.net/zhoufenqin/article/details/50497791 题目出处:https://www.patest.cn/contests/pa ...

  8. Android GradientDrawable(shape标签定义) 静态使用和动态使用(圆角,渐变实现)

    Android GradientDrawable使用优势: 1. 快速实现一些基本图形(线,矩形,圆,椭圆,圆环) 2. 快速实现一些圆角,渐变,阴影等效果 3. 代替图片设置为View的背景 4. ...

  9. AlloyRenderingEngine之Shape

    写在前面 不读文章,只对代码感兴趣可以直接跳转到这里 https://github.com/AlloyTeam/AlloyGameEngine 然后star一下,多谢支持:). 游戏或者应用中,不是所 ...

随机推荐

  1. Atcoder Beginner Contest 147C(状态压缩)

    最多15个人,用N个二进制的数字表示每个人的状态,然后检验.这串数字相当于已经把这些人的状态定了下来,如果和输入的情况不符则这串数字不正确,直接忽略,因为枚举了所有的情况,所以总有正确的,不必在错误的 ...

  2. Educational Codeforces Round 78 (Rated for Div. 2)D(并查集+SET)

    连边的点用并查集检查是否有环,如果他们的fa是同一个点说明绕了一圈绕回去了.n个点一共能连n-1条边,如果小于n-1条边说明存在多个联通块. #define HAVE_STRUCT_TIMESPEC ...

  3. ACM的探索之Everything Is Generated In Equal Probability(这真的是很有趣的话语丫!)

    ---------------------------------------步履不停,奋勇前进! ------------------------难度真的是蛮大丫!后序补充!

  4. js中的日期控件My97 DatePicker

    使用WdatePicker插件来渲染日期类型的页面. 以下代码用到的属性有: isShowClear是否显示清空按钮 skin皮肤的样式 readOnly是否只读 maxDate:最大的选择时间 &l ...

  5. PTA的Python练习题(十六)

    第4章-15 换硬币 挺难的,这里学到一个range的用法: 也就是说range函数能实现顺序和倒序,取决于step是正是负 count = 0 x = int(input()) a = x // 5 ...

  6. Bug搬运工-CSCvf74866:Webauth scaling improvements - fix problem with GUI going unresponsive with HTTPS redirect

    Webauth scaling improvements - fix problem with GUI going unresponsive with HTTPS redirect CSCvf7486 ...

  7. plutosdr初步

    关于最近新出的pluto sdr ,一款较新的sdr,可以通过破解将ad9363改成ad9361,提升频率范围,但是据说没有办法改变带宽. 可以通过补丁方式使用某款软件来进行收听fm

  8. fiddler的代理设置

    fiddler通过监听系统的8888端口实现对系统浏览器发出的http报文进行截获监听,因此要使fiddler能够监听到浏览器数据,需要对浏览器设置代理端口 浏览器 <--8888端口代理--& ...

  9. 深入剖析Windows专业版安装Docker引擎和Windows家庭版Docker引擎安装的区别

    原创声明:作者:Arnold.zhao  博客园地址:https://www.cnblogs.com/zh94 公司使用的电脑是Windows专业版,所以配置本机的Docker时会方便许多,后续由于需 ...

  10. vim 一些操作

    在ESC下 gg # 光标跳到开头 dG # 删除光标后的数据 dd # 删除光标所在行 gg dG # 删除全部 (光标跳到开头&删除光标后的数据) x # 删除当前光标下的字符 i # 编 ...