POJ2533Longest Ordered Subsequence(DP)
http://poj.org/problem?id=2533
在经典不过的DP题目了。。。。
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
#define mem0(a) memset(a,0,sizeof(a)) typedef long long LL;
const double eps = 1e-;
const int MAXN = ;
const int MAXM = ; int DP[], a[], N; int BinarySearch(int low, int high, int val)
{
while(low < high)
{
int mid = (low + high) >> ;
if(DP[mid] < val) low = mid +;
else high = mid;
}
return low;
} int main()
{
while(~scanf("%d", &N))
{
for(int i=;i<=N;i++)
{
scanf("%d", &a[i]);
}
DP[] = a[];
int len = ;
for(int i=;i<=N;i++)
{
int id = BinarySearch(, len+, a[i]);
DP[id] = a[i];
if(id > len) ++len;
}
printf("%d\n", len);
}
return ;
}
POJ2533Longest Ordered Subsequence(DP)的更多相关文章
- poj2533--Longest Ordered Subsequence(dp:最长上升子序列)
Longest Ordered Subsequence Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 33943 Acc ...
- POJ 2533-Longest Ordered Subsequence(DP)
Longest Ordered Subsequence Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 34454 Acc ...
- POJ 2533——Longest Ordered Subsequence(DP)
链接:http://poj.org/problem?id=2533 题解 #include<iostream> using namespace std; ]; //存放数列 ]; //b[ ...
- POJ 2533 Longest Ordered Subsequence(DP 最长上升子序列)
Longest Ordered Subsequence Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 38980 Acc ...
- POJ 2533 Longest Ordered Subsequence(dp LIS)
Language: Default Longest Ordered Subsequence Time Limit: 2000MS Memory Limit: 65536K Total Submis ...
- Poj 2533 Longest Ordered Subsequence(LIS)
一.Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequenc ...
- poj-2533 longest ordered subsequence(动态规划)
Time limit2000 ms Memory limit65536 kB A numeric sequence of ai is ordered if a1 < a2 < ... &l ...
- HPU第三次积分赛-D:Longest Increasing Subsequence(DP)
Longest Increasing Subsequence 描述 给出一组长度为n的序列,a1,a2,a3,a4...an, 求出这个序列长度为k的严格递增子序列的个数 输入 第一行输入T ...
- HDU 1159 Common Subsequence (dp)
题目链接 Problem Description A subsequence of a given sequence is the given sequence with some elements ...
随机推荐
- wordpress plugins collection
1/ simple page ordering 4.8星 wordpress的plugins唯一的好处就是命名简单易懂,这款插件从名称就可以看出来,用来对page页面排序的.只需要在后台page中拖拽 ...
- 一个基于PDO的数据库操作类(新) 一个PDO事务实例
<?php /* * 作者:胡睿 * 日期:2011/03/19 * 电邮:hooray0905@foxmail.com * * 20110319 * 常用数据库操作,如:增删改查,获取单条记录 ...
- 图形编程(数值微分DDA)
#include <iostream> #include <time.h> #include <stdio.h> #include <stdlib.h> ...
- 【C#学习笔记】保存文件
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- js中substring和substr的用法
js中substring和substr的用法 substring 方法用于提取字符串中介于两个指定下标之间的字符 substring(start,end) 开始和结束的位置,从零开始的索引 参数 ...
- 【转】Github轻松上手2-如何使用命令行创建和管理repo
转自:http://blog.sina.com.cn/s/blog_4b55f6860100zzhd.html 如果你对这种怀旧的方式很感冒,不妨参考这里: http://help.github.co ...
- 用于科创的git log美化输出
git log --reverse --pretty=format:'%cd %s' --date=short > a.txt 更好的: git log --reverse --pretty=f ...
- php 正则中的"i,m,s,x,e"分别表示什么
i如果设定此修正符,模式中的字符将同时匹配大小写字母.m当设定了此修正符,“行起始”和“行结束”除了匹配整个字符串开头和结束外,还分别匹配其中的换行符的之后和之前.s如果设定了此修正符,模式中的圆点元 ...
- Linux中用stat命令查看文件时3个时间点解析
有些时候,我们需要在Linux中使用stat命令来查看文件的详细信息.另外联想下,ls -l命令显示的是什么时间,touch命令修改文件的时间戳,修改的又是什么时间?在这里我们一起来试验下. 首先,我 ...
- Effective java笔记8--序列化
对象的序列化(object serialization)API,它提供了一个框架,用来将对象编码成一个字节流,以及从字节流编码中重新构建对象. 一.谨慎地实现Serializable 要想使一 ...