POJ 3903 —— Stock Exchange 最长上升子序列
2016-03-07 21:10
225 查看
原题:http://poj.org/problem?id=3903
题意:求最长上升子序列的个数;
题意:求最长上升子序列的个数;
#include<cstdio> #include<algorithm> using namespace std; const int maxn = 1000000+10; int stack[maxn]; int n; int main() { while(~scanf("%d", &n)) { int top = 0; stack[top] = -1; for(int i = 1;i<=n;i++) { int tmp; scanf("%d", &tmp); if(tmp > stack[top]) stack[++top] = tmp; else { int pos = lower_bound(stack+1, stack+top+1, tmp) - stack; stack[pos] = tmp; } } printf("%d\n", top); } return 0; }
相关文章推荐
- Android OkHttp之 offline cache
- 从爬取湖北某高校hub教务系统课表浅谈Java信息抓取的实现 —— import java.*;
- [国嵌攻略][117][LED驱动程序设计]
- java里的静态变量是放在了堆内存还是栈内存?
- 杭电1284
- hdoj 1220 Cube
- Java设计模式之访问者模式
- 【数据结构】堆
- php日记——配置的坑
- 算法训练 学做菜
- at org.apache.jsp.index_jsp._jspInit(index_jsp.java:23)异常解决
- php MySQL使用rand函数随机取记录(转)
- HTML第一讲
- 位域与大小端问题
- 调试Lattice serdes
- 2016蓝桥杯假期任务之《回文数字》
- Android开发中使用AndroidStudio与Eclipse的代码区别----自定义控件时自定义属性
- Large-scale Video Classification with Convolution Neural Networks
- 验证码图像识别-python
- ASP.NET(C#)——加一列按钮