博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
sdnu 1172.Queue 【LIS】
阅读量:4627 次
发布时间:2019-06-09

本文共 1638 字,大约阅读时间需要 5 分钟。

1172.Queue

Time Limit: 1000 MS    Memory Limit: 32768 KB
Total Submission(s):     Accepted Submission(s): 

Description

    On the PE,the teacher wants to choose some of n students to play games. Teacher asks n students stand in a line randomly(obviously,they have different height), then teacher tells someone to leave the queue(relative position is not change)to make the left students keep a special queue: 
    Assuming that the left students’ numbers are 1, 2,……, m from left to right and their height are T1,T2,……,Tm. Then they satisfy T1<T2<......<Ti, Ti><t2<……<ti,ti>Ti+1>……>Tm (1<=i<=m).
    Giving you the height of n students (from left to right), please calculate how many students left at most if you want to keep such a special queue. 

Input

    The first line contains an integer n (2<=n<=1000) represents the number of students.
    The second line contains n integers Ti(150<=Ti<=200) separated by spaces, represent the height(cm) of student i. 

Output

    One integer represents the number of the left students.

Sample Input

8186 180 150 183 199 130 190 180

Sample Output

5

Hint

 

Source

Unknown
枚举每一个位置的max(正向到此位置的LIS+逆向到此位置的LIS),ans需要-1
#include 
using namespace std;int dp1[1005],dp2[1005],a[1005],b[1005];int main(){ int n; while(scanf("%d",&n)!=EOF) { for(int i=1;i<=n;i++) { scanf("%d",&a[i]); b[n-i+1]=a[i]; } memset(dp1,0,sizeof(dp1)); memset(dp2,0,sizeof(dp2)); dp1[1]=1; dp2[1]=1; for(int i=2;i<=n;i++) { dp1[i]=1; dp2[i]=1; for(int j=1;j

 

转载于:https://www.cnblogs.com/guanwen769aaaa/p/11238895.html

你可能感兴趣的文章
2017年50道Java线程面试题
查看>>
better-scroll
查看>>
TSP问题——动态规划
查看>>
java多线程三之线程协作与通信实例
查看>>
japid-controller自动绑定的数据类型
查看>>
获取应用程序路径信息
查看>>
vm.max_map_count
查看>>
OSI模型第四层传输层--TCP协议
查看>>
web service 项目 和 普通 web项目 的 区别
查看>>
Linux结构目录
查看>>
ajax frameworks(转贴)
查看>>
javascript禁止修改对象
查看>>
What Are Words(一诺千金)
查看>>
javaScript 工作必知(三) String .的方法从何而来?
查看>>
ubutun:从共享文件夹拷贝文件尽量使用cp命令而不是CTRL+C/V
查看>>
JQUERY动态生成当前年份的前5年以及后 2年
查看>>
MVC3学习 四 EF删除操作
查看>>
IncDec Sequence(codevs 2098)
查看>>
分裂游戏(bzoj 1188)
查看>>
使用 Azure CLI 管理 Azure 虚拟网络和 Linux 虚拟机
查看>>