Bridging signals hdu 1950 (最长上升子序列)
http://acm.split.hdu.edu.cn/showproblem.php?pid=1950
题意:求最长上升(不连续or连续)子序列
推荐博客链接:
http://blog.csdn.net/sinat_30062549/article/details/47197073
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <math.h> using namespace std; #define INF 0x3f3f3f3f
const int maxn = ;
typedef long long LL;
int a[maxn], s[maxn]; int main()
{
int T, n; scanf("%d", &T); while(T --)
{
scanf("%d", &n); for(int i=; i<=n; i++)
scanf("%d", &a[i]); int len = ;
memset(s, , sizeof(s)); for(int i=; i<=n; i++)
{
if(a[i]>=s[len])
{
s[++len]=a[i];
continue;
} int pos = upper_bound(s, s+len, a[i])-s;///找出s数组中比a[i]大的数字的下标
s[pos] = a[i];
} printf("%d\n", len);
}
return ;
}
Bridging signals hdu 1950 (最长上升子序列)的更多相关文章
- poj 1631 Bridging signals (二分||DP||最长递增子序列)
Bridging signals Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 9234 Accepted: 5037 ...
- Bridging signals(NlogN最长上升子序列)
Bridging signals Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- hdu 1950 最长上升子序列(lis) nlogn算法【dp】
这个博客说的已经很好了.http://blog.csdn.net/shuangde800/article/details/7474903 简单记录一下自己学的: 问题就是求一个数列最长上升子序列的长度 ...
- hdu 1950 最长上升子序列
//Accepted 3540 KB 62 ms //dp 最长上升子序列 #include <cstdio> #include <cstring> #include < ...
- hdoj 1950 Bridging signals【二分求最大上升子序列长度】【LIS】
Bridging signals Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- HDU 5773 最长上升子序列
题意 给出一个序列 问它的最长严格上升子序列多长 这个序列中的0可以被替代为任何数 n的范围给出了1e5 所以平常的O(n*n)lis不能用了 在kuangbin的模板里有O(nlogn)的模板 套上 ...
- HDU 5748 最长上升子序列的长度nlogn(固定尾部)
Bellovin Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total ...
- HDU 1025(最长上升子序列)
题意是要在两条平行线间连点,要在线不交叉的前提下尽可能多的连线,问最多能连多少条线. 现假定题中所给的是 9 组点,分别是:1—3,2—8,3—5,4—9,5—2,6—4,7—6,8—7,9—1,如图 ...
- HDU 1159 最长公共子序列(n*m)
Common Subsequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
随机推荐
- apache 配置多个虚拟主机,不同的端口
1.在httpd.conf添加多个端口,如下 Listen 80Listen 8080 2.开启Include conf/extra/httpd-vhosts.conf 3.具体代码如下 <Vi ...
- eclipse下tomcat插件配置说明
- (转)DataGridView多维表头及其扩展功能
dataGridView1.RowHeadersVisible = false;把整行选中那一列去掉.如果需要整行选中,新增一按钮列模拟实现.上源码:多维DataGridView 有个简易的方法: 1 ...
- gcc-常见命令和错误
一:编译过程的4个阶段:预处理,编译,汇编,链接; 1:最常用的方式 gcc hello.c -o hello 2:预处理后停止编译 gcc -E hello.c -o hello.i(.i通常为 ...
- 'libxml/tree.h' file not found
看看Header Search Paths 为 '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Dev ...
- 【Linux】netdata监控组件
github:https://github.com/firehol/netdata 安装:https://github.com/firehol/netdata/wiki/Installation 内存 ...
- SQL Server常用技巧
1:在SQL语句中,将存储过程结果集(表)存入到临时表中 insert into #tmp EXEC P_GET_AllChildrenComany '80047' 说明:#tmp要提前创建好 2:字 ...
- JS驗證兩位小數
function SizeCheck(Textdiv) { var fg = true; str = $("#" + T ...
- WAMP(Windows、Apache、MySQL、php)安装配置过程常见问题
WAMP(Windows.Apache.MySQL.php)安装配置过程 可以参考该网友的总结(总结的不错,鼓掌!!): http://www.cnblogs.com/pharen/archive/2 ...
- web.xml的首页调用struts2的action解决方法
1,首先在struts.xml里添加如下代码:注意位置 <constant name="struts.action.extension" value="do,act ...