HDU 5773The All-purpose Zero
The All-purpose Zero
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 231 Accepted Submission(s): 101
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.
1 2 3 3 0 0
In the first case,you can change the second 0 to 3.So the longest increasing subsequence is 0 1 2 3 5.
/* ***********************************************
Author :guanjun
Created Time :2016/7/28 15:51:43
File Name :p410.cpp
************************************************ */
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 0x3f3f3f3f
#define maxn 100010
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << ;
const double eps=1e-;
using namespace std;
priority_queue<int,vector<int>,greater<int> >pq;
struct Node{
int x,y;
};
struct cmp{
bool operator()(Node a,Node b){
if(a.x==b.x) return a.y> b.y;
return a.x>b.x;
}
}; bool cmp(int a,int b){
return a>b;
}
int d[maxn];
int a[maxn];
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
int T,n,cnt;
cin>>T;
for(int t=;t<=T;t++){
cin>>n;
for(int i=;i<=n;i++)scanf("%d",&a[i]);
int len=;
cnt=;
for(int i=;i<=n;i++){
if(a[i]==)cnt++;
else {
a[i]-=cnt;
int pos=lower_bound(d,d+len,a[i])-d;
if(pos==len){
d[len++]=a[i];
}
else d[pos]=a[i];
}
}
printf("Case #%d: %d\n",t,len+cnt);
}
return ;
}
HDU 5773The All-purpose Zero的更多相关文章
- HDU 5813 Elegant Construction(优雅建造)
HDU 5813 Elegant Construction(优雅建造) Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65 ...
- HDU 5813 Elegant Construction (贪心)
Elegant Construction 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5813 Description Being an ACMer ...
- HDU 3072 Intelligence System (强连通分量)
Intelligence System Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- hdu 3038 How Many Answers Are Wrong
http://acm.hdu.edu.cn/showproblem.php?pid=3038 How Many Answers Are Wrong Time Limit: 2000/1000 MS ( ...
- HDU 5813 Elegant Construction 构造
Elegant Construction 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5813 Description Being an ACMer ...
- HDU 3038 - How Many Answers Are Wrong - [经典带权并查集]
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3038 Time Limit: 2000/1000 MS (Java/Others) Memory Li ...
- HDU 3038 How Many Answers Are Wrong 【YY && 带权并查集】
任意门:http://acm.hdu.edu.cn/showproblem.php?pid=3038 How Many Answers Are Wrong Time Limit: 2000/1000 ...
- HDU 1937 J - Justice League
J - Justice League Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u ...
- HDU 2435 There is a war
There is a war Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. Original ...
随机推荐
- extjs中Store和grid的刷新问题
问题1:Store.load() 和Store.setproxy()区别 问题2:修改后的Grid 更新: Store.reload() 问题3,store删除后刷新会出问题 Store移除一行:St ...
- 笔试算法题(30):从已排序数组中确定数字出现的次数 & 最大公共子串和最大公共序列(LCS)
出题:在已经排序的数组中,找出给定数字出现的次数: 分析: 解法1:由于数组已经排序,所以可以考虑使用二分查找确定给定数字A的第一个出现的位置m和最后一个出现的位置n,最后m-n+1就是A出现的次数: ...
- 使用maven的mybatis-generator代码生成器插件生成实体类、mapper配置文件和mapper接口(使用idea)
接着之前创建的ssmMaven项目 一: 在pom文件中加入mybatis-generator插件 <plugins> <plugin> <groupId>org. ...
- 零基础入门学习Python(23)--递归:这帮小兔崽子
知识点 我们都知道兔子繁殖能力是惊人的,如下图: 我们可以用数学函数来定义: 假设我们需要求出经历了20个月后,总共有多少对小兔崽子? 迭代实现 def fab(n): n1 = 1 n2 = 1 n ...
- 【转】C语言中access函数
头文件:unistd.h 功 能: 确定文件或文件夹的访问权限.即,检查某个文件的存取方式,比如说是只读方式.只写方式等.如果指定的存取方式有效,则函数返回0,否则函数返回-1. 用 法: int a ...
- PDO、PDOStatement、PDOException
最近在学PDO 比较详细的资料 出处:http://blog.csdn.net/hsst027/article/details/23682003 PDO中包含三个预定义的类,它们分别是PDO.PDO ...
- table中JS选取行列
<table border="1" align="center" style="width: 500px" id="doct ...
- noi.ac NOIP2018 全国热身赛 第二场 T3 color
[题解] 我们可以发现每次修改之后叶子结点到根的路径最多分为两段:一段白色或者黑色,上面接另一段灰色的.二分+倍增找到分界点,然后更新答案即可. check的时候只需要判断当前节点对应的叶子结点的区间 ...
- python——文件管理
文件操作分为读.写.修改 一.读文件 f = open(file='D:/工作日常/兼职白领学生空姐模特护士联系方式.txt',mode='r',encoding='utf-8') data = f. ...
- 【05】emmet系列之各种缩写
[01]emmet系列之基础介绍 [02]emmet系列之HTML语法 [03]emmet系列之CSS语法 [04]emmet系列之编辑器 [05]emmet系列之各种缩写 各种缩写 缩写:! & ...