题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87125#problem/E

题目:

Description

The world financial crisis is quite a subject. Some people are more relaxed while others are quite anxious. John is one of them. He is very concerned about the evolution of the stock exchange. He follows stock prices every day looking for rising trends. Given a sequence of numbers p1, p2,...,pn representing stock prices, a rising trend is a subsequence pi1 < pi2 < ... < pik, with i1 < i2 < ... < ik. John’s problem is to find very quickly the longest rising trend.

Input

Each data set in the file stands for a particular set of stock prices. A data set starts with the length L (L ≤ 100000) of the sequence of numbers, followed by the numbers (a number fits a long integer). 
White spaces can occur freely in the input. The input data are correct and terminate with an end of file.

Output

The program prints the length of the longest rising trend. 
For each set of data the program prints the result to the standard output from the beginning of a line.

Sample Input

6
5 2 1 4 5 3
3
1 1 1
4
4 3 2 1

Sample Output

3
1
1

Hint

There are three data sets. In the first case, the length L of the sequence is 6. The sequence is 5, 2, 1, 4, 5, 3. The result for the data set is the length of the longest rising trend: 3.
 
 
题意:
   一道LIS的裸题,给定一组数据,让我们求出这组数据的最大上升的序列包含元素的个数。
思路:
    要注意数据比较多,要用二分法的优化法(O(nlogn))。
 

#include<iostream>
#include<cstdio>
using namespace std;
const int maxn=;
int a[maxn],b[maxn];
int main()
{
int n,i,L,mid;
while(scanf("%d",&n)!=EOF)
{
a[]=-;
int count=;
int Max=;
for(i=;i<=n;i++)
cin>>a[i];
for(i=;i<=n;i++)
{
if(a[i]>b[count])
b[++count]=a[i];
else
{
Max=count;
L=;
while(L<=Max)
{
mid=(L+Max)/;
if(b[mid]<a[i])
L=mid+;
else Max=mid-;
}
b[L]=a[i];
}
}
cout<<count<<endl;
}
return ;
}

POJ3903:Stock Exchange(LIS)的更多相关文章

  1. POJ 3903:Stock Exchange(裸LIS + 二分优化)

    http://poj.org/problem?id=3903 Stock Exchange Time Limit: 1000MS   Memory Limit: 65536K Total Submis ...

  2. POJ3903 Stock Exchange LIS最长上升子序列

    POJ3903 Stock Exchange #include <iostream> #include <cstdio> #include <vector> #in ...

  3. POJ - 3903 Stock Exchange(LIS最长上升子序列问题)

    E - LIS Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u   Descripti ...

  4. POJ 3903 Stock Exchange (E - LIS 最长上升子序列)

    POJ 3903    Stock Exchange  (E - LIS 最长上升子序列) 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action ...

  5. poj3903 Stock Exchange(最长上升子序列)

    转载请注明出处:http://blog.csdn.net/u012860063 题目链接:id=3903">http://poj.org/problem?id=3903 Descrip ...

  6. Poj 3903 Stock Exchange(LIS)

    一.Description The world financial crisis is quite a subject. Some people are more relaxed while othe ...

  7. poj3903 Stock Exchange 二分+dp

    题目地址:http://poj.org/problem?id=3903 题目: Description The world financial crisis is quite a subject. S ...

  8. POJ 3903 Stock Exchange

    Stock Exchange Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2954   Accepted: 1082 De ...

  9. 品友推广的投放原理 RTB:Real Time Bidding(实时竞价) DSP:Demand-Side Platform(需求方平台) 广告交易平台:AD Exchange

    总结: 1.实时竞价 0.1秒出价各个广告主出价,投放价高者: RTB(Real Time Bidding)实时竞价,是一种利用第三方技术在数以百万计的网站或移动端针对每一个用户展示行为进行评估以及出 ...

随机推荐

  1. wp8 入门到精通 Animation 背景加字体颜色从下向上变化颜色效果

    <phone:PhoneApplicationPage.Resources> <Style x:Key="ButtonStyle1" TargetType=&qu ...

  2. 您的 PHP 似乎没有安装运行 WordPress 所必需的 MySQL 扩展”处理方法

    转自:http://www.xuebuyuan.com/1549022.html 这已经是一个老掉牙的问题了,部分人使用自己的服务器安装WordPress程序之后,会出现“您的 PHP 似乎没有安装运 ...

  3. 几个国内速度最快的centos yum(更新源)

    转自:http://blog.itpub.net/15711267/viewspace-1068862/ 中国科技大学源 cd /etc/yum.repos.d mv CentOS-Base.repo ...

  4. Windows Path设置

    win7系统环境变量path的两种设置方法   环境变量Path    环境变量是在操作系统中一个具有特定名字的对象,它包含了一个或者多个应用程序所将使用到的信息.例如Windows和DOS操作系统中 ...

  5. for循环嵌套

    今天复习了分支语句以及for循环,新内容主要讲解了for循环的嵌套: 外循环控制行,内循环控制列 下面几个实例: 五行五列的矩阵 左下角是直角的三角形: 左上角是直角的三角形: 右上角为直角的三角形: ...

  6. Understanding, Operating and Monitoring Apache Kafka

    Apache Kafka is an attractive service because it's conceptually simple and powerful. It's easy to un ...

  7. AJAX案例二:简单表单验证

    案例:如果用户名输入为张三,那么在失去焦点时后面会显示该用户名已被注册,否则显示可以注册! <%@ page language="java" import="jav ...

  8. Spring的LoadTimeWeaver(代码织入)

    在Java 语言中,从织入切面的方式上来看,存在三种织入方式:编译期织入.类加载期织入和运行期织入.编译期织入是指在Java编译期,采用特殊的编译器,将切面织入到Java类中:而类加载期织入则指通过特 ...

  9. 基线 css

    原文地址:http://blog.jobbole.com/31926/ 英文原文:CSS Baseline,编译:飞鸟分享 译者注:网页设计布局中一直比较流行网格对齐,但只是针对水平的对齐,很少或者没 ...

  10. 《DSP using MATLAB》示例Example5.4