hdu-5773 The All-purpose Zero(LIS)
题目链接:
The All-purpose Zero
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 65536/65536 K (Java/Others)
For each case,the first line contains an interger n,which is the length of the array s.
The next line contains n intergers separated by a single space, denote each number in S.
/************************************************
┆ ┏┓ ┏┓ ┆
┆┏┛┻━━━┛┻┓ ┆
┆┃ ┃ ┆
┆┃ ━ ┃ ┆
┆┃ ┳┛ ┗┳ ┃ ┆
┆┃ ┃ ┆
┆┃ ┻ ┃ ┆
┆┗━┓ ┏━┛ ┆
┆ ┃ ┃ ┆
┆ ┃ ┗━━━┓ ┆
┆ ┃ AC代马 ┣┓┆
┆ ┃ ┏┛┆
┆ ┗┓┓┏━┳┓┏┛ ┆
┆ ┃┫┫ ┃┫┫ ┆
┆ ┗┻┛ ┗┻┛ ┆
************************************************ */ #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>
#include <stack> using namespace std; #define For(i,j,n) for(int i=j;i<=n;i++)
#define mst(ss,b) memset(ss,b,sizeof(ss)); typedef long long LL; template<class T> void read(T&num) {
char CH; bool F=false;
for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar());
for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar());
F && (num=-num);
}
int stk[70], tp;
template<class T> inline void print(T p) {
if(!p) { puts("0"); return; }
while(p) stk[++ tp] = p%10, p/=10;
while(tp) putchar(stk[tp--] + '0');
putchar('\n');
} const LL mod=20071027;
const double PI=acos(-1.0);
const int inf=1e9;
const int N=1e5+100;
const int maxn=(1<<8);
const double eps=1e-8; int a[N],sum,d[N],g[N]; int main()
{
int t,Case=0;
read(t);
while(t--)
{
int n,cnt=0,x;
read(n);
sum=0;
For(i,1,n)
{
read(x);
if(x==0)sum++;
else a[++cnt]=x-sum;
g[i]=inf;
}
int ans=0;
For(i,1,cnt)
{
int temp=lower_bound(g+1,g+cnt+1,a[i])-g;
g[temp]=a[i];
ans=max(ans,temp);
}
printf("Case #%d: %d\n",++Case,ans+sum);
}
return 0;
}
hdu-5773 The All-purpose Zero(LIS)的更多相关文章
- HDU 5773 The All-purpose Zero (变形LIS)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5773 0可以改变成任何数,问你严格递增的子序列最长是多少. 猜测0一定在最长上升子序列中用到,比如2 ...
- HDU 5773 The All-purpose Zero 求LIS
求最长上升子序列长度: 单纯的dp时间复杂度是O(n*n)的 dp[i] = max(dp[j]+1); (0=<j<=i-1 && a[i]>a[j]) 用二分可以 ...
- HDU 5773 The All-purpose Zero 脑洞LIS
给定一个序列,里面的0是可以任变的.问变化后最长的LIS的长度 首先,0全部选上是不亏的.这个不知道怎么说,YY一下吧. 最关键的就是解决2 0 0 3 这种问题了. 注意到这个序列的LIS应该是3 ...
- hdu 5773 The All-purpose Zero 最长上升子序列+树状数组
题目链接:hdu 5773 The All-purpose Zero 官方题解:0可以转化成任意整数,包括负数,显然求LIS时尽量把0都放进去必定是正确的. 因此我们可以把0拿出来,对剩下的做O(nl ...
- HDU 5773 The All-purpose Zero(O(nlgn)求LIS)
http://acm.hdu.edu.cn/showproblem.php?pid=5773 题意: 求LIS,其中的0可以看做任何数. 思路: 因为0可以看做任何数,所以我们可以先不管0,先求一遍L ...
- HDU 5773:The All-purpose Zero(贪心+LIS)
http://acm.hdu.edu.cn/showproblem.php?pid=5773 The All-purpose Zero Problem Description ?? gets an ...
- hdu 5773 The All-purpose Zero 线段树 dp
The All-purpose Zero 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5773 Description ?? gets an seq ...
- HDU 5087 (线性DP+次大LIS)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5087 题目大意:求次大LIS的长度.注意两个长度相同的LIS大小比较,下标和大的LIS较大. 解题思 ...
- 【动态规划】【二分】【最长上升子序列】HDU 5773 The All-purpose Zero
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5773 题目大意: T组数据,n个数(n<=100000),求最长上升子序列长度(0可以替代任何 ...
- HDU 5773 The All-purpose Zero(树状数组)
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5773 [题目大意] 给出一个非负整数序列,其中的0可以替换成任意整数,问替换后的最长严格上升序列长 ...
随机推荐
- Android学习笔记(35):Android活动条
在Android3.0之后,Google对UI导航设计上进行了一系列的改革,当中有一个很好用的新功能就是引入的ActionBar,用于代替3.0之前的标题栏,并提供更为丰富的导航效果. ActionB ...
- php自己编译安装后,再给这个编译安装的php版本添加拓展模块的处理办法。
原文: https://www.cnblogs.com/zongyl/p/5924627.html 说明,给编译安装之后的php 添加pgsql 拓展成功. --------------------- ...
- 合并SO为单独交货单
本场景为单步交货 为客户建立专用的route. 增加一个pull rule 在做订单的时候,为订单行选择 上面建立好的route, 连续建立了 2个 订单 SO ...
- Unable to satisfy the following requirements解决方式
今天从git上面download我们项目,然后向往常一样安装Cocoapods.可是却突然发现报错了,尝试了几遍.发现一直报错. 然后我这才看了一下,安装Cocoapods的日志,发现抛出了一个报错. ...
- Tachyon源代码结构分析(二)
公布人:南京大学PASA大数据实验室顾荣 前言 在上一篇<Tachyon源代码结构分析(一)>中,我们介绍了Tachyon的四大模块(Client模块.Master模块.Worker模块以 ...
- JavaScript的string方法(demo)
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- pjblog支持QQ、新浪微博一键登录
转载地址: http://www.ruisoftcn.com/blog/article.asp?id=955
- <LeetCode OJ> 337. House Robber III
Total Accepted: 1341 Total Submissions: 3744 Difficulty: Medium The thief has found himself a new pl ...
- Nginx详细的安装教程(linux)
转:https://blog.csdn.net/u013641234/article/details/73838472 Nginx作为一个web服务器,目前使用最多的就利用其负载均衡,本篇着重讲解的是 ...
- React_Redux_Router
一.react_redux 比较好的blog: blog1, blog2, blog3 主要根据前两个blog总结如下: 1. React在组件内部(包括子组件)为单向数据流且自上向下通过props传 ...