题意:

序列arr[i--n];输出以a[i]为结尾的最长上升子序列。1<=n<=100000;

思路:

O(n*log(n)),求最长上升子序列。
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 100000+100;
int arr[maxn];
int main ()
{
int T;scanf("%d",&T);
while(T--)
{
int n,k=0;scanf("%d",&n);
for(int i=1;i<=n;i++)
{
int t;
scanf("%d",&t);
int pos=int(lower_bound(arr,arr+k,t)-arr);
printf("%d",pos+1);
if(i<n)
printf(" ");
if(pos==k)
k++;
arr[pos]=t;
}
printf("\n");
}
return 0;
}

div.2/Bellovin<最长上升子序列>的更多相关文章

  1. hdu 5748 Bellovin【最长上升子序列】

    题目链接:https://vjudge.net/contest/148584#problem/A 题目大意: 解题思路:题目要求为:输出与已知序列的每一个元素的f(i)(f(i)的定义如题)相同的字典 ...

  2. Codeforces Round #345 Div.1 D.Zip-line 动态最长上升子序列

    题意概述: 给出一个长度为N的序列和M组询问,问假设把某个位置的值改成另一个给出的值之后,序列的最长上升子序列的长度. N,M<=400000. 分析: 考虑某个位置的值改动后这个位置和最长上升 ...

  3. codeforces #345 (Div. 1) D. Zip-line (线段树+最长上升子序列)

    Vasya has decided to build a zip-line on trees of a nearby forest. He wants the line to be as long a ...

  4. HDU 5748 最长上升子序列的长度nlogn(固定尾部)

    Bellovin Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total ...

  5. 用python实现最长公共子序列算法(找到所有最长公共子串)

    软件安全的一个小实验,正好复习一下LCS的写法. 实现LCS的算法和算法导论上的方式基本一致,都是先建好两个表,一个存储在(i,j)处当前最长公共子序列长度,另一个存储在(i,j)处的回溯方向. 相对 ...

  6. 动态规划之最长公共子序列(LCS)

    转自:http://segmentfault.com/blog/exploring/ LCS 问题描述 定义: 一个数列 S,如果分别是两个或多个已知数列的子序列,且是所有符合此条件序列中最长的,则 ...

  7. [Data Structure] LCSs——最长公共子序列和最长公共子串

    1. 什么是 LCSs? 什么是 LCSs? 好多博友看到这几个字母可能比较困惑,因为这是我自己对两个常见问题的统称,它们分别为最长公共子序列问题(Longest-Common-Subsequence ...

  8. 动态规划求最长公共子序列(Longest Common Subsequence, LCS)

    1. 问题描述 子串应该比较好理解,至于什么是子序列,这里给出一个例子:有两个母串 cnblogs belong 比如序列bo, bg, lg在母串cnblogs与belong中都出现过并且出现顺序与 ...

  9. LintCode 77: 最长公共子序列

    public class Solution { /** * @param A, B: Two string. * @return: the length of the longest common s ...

随机推荐

  1. Java 泛型 泛型数组

    Java 泛型 泛型数组 @author ixenos 先给结论 不能(直接)创建泛型数组 泛型数组实际的运行时对象数组只能是原始类型( T[]为Object[],Pair<T>[]为Pa ...

  2. js提交form表单

    <form action="/Enterprise/member" id="sendinviteid" method="post"&g ...

  3. Infix to postfix without '(' and ')'

    #include<iostream> #include<stack> #include<string> #include<deque> using na ...

  4. 重装系统之后Hexo快速配置

    安装准备软件 Node.js Git 打开 Git Bash hexo文件夹,右键: 配置SSH Keys 检查SSH keys设置,看一下电脑现有的ssh key cd ~/. ssh 检查本机的s ...

  5. LeetCode OJ 39. Combination Sum

    Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C wher ...

  6. wuzhi 五指 伪静态

    rewrite ^(.*)list\/([0-9]+)-([0-9]+)\.html$ $1index.php?v=listing&cid=$2&page=$3 last; rewri ...

  7. varnish屏蔽control+F5导致缓存失效

    刚刚接触Varnish缓存,对静态资源进行缓存.目前问题,当浏览器Control+F5刷新页面,导致缓存失效. 参照:http://zhangxugg-163-com.iteye.com/blog/1 ...

  8. JS全选

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"% ...

  9. EF Unit Of Work

    BaseEntity, 所有的业务表都继承这个类,每个表的主键都是GUID, 主键名Id. public abstract class BaseEntity{ public BaseEntity() ...

  10. MyBatis 批量修改记录

    <insert id="update" parameterType="java.util.List"> UPDATE setting SET con ...