给出导弹的高度 拦截的导弹会比上一次低 至少要几套拦截系统才能防御所有导弹

求一套系统能防御的最大导弹数: 反向LIS
求一共要多少套:正向LIS

Sample Input
8 389 207 155 300 299 170 158 65

Sample Output
2

 # include <iostream>
# include <cstdio>
# include <cstring>
# include <algorithm>
# include <cmath>
# define LL long long
using namespace std ; int a[] ;
int f[] ;
//int dp[100010] ;
int n ; int bsearch(int size, const int &a) {
int l=, r=size-;
while( l <= r ){
int mid = (l+r)/;
if( a > f[mid-] && a <= f[mid] ) return mid;// >&&<= 换为: >= && <
else if( a < f[mid] ) r = mid-;
else l = mid+;
}
} int LIS()
{
int i, j, size = ;
f[] = a[];
//dp[0] = 1;
for( i=; i < n; ++i )
{
if( a[i] <= f[] ) j = ; // <= 换为: <
else if( a[i] > f[size-] ) j = size++;// > 换为: >=
else j = bsearch(size, a[i]);
f[j] = a[i];
//dp[i] = j+1;
}
return size;
} int main ()
{
//freopen("in.txt","r",stdin) ;
while(scanf("%d" , &n) !=EOF)
{
int i ;
for (i = ; i < n ; i++)
scanf("%d" , &a[i]) ;
printf("%d\n" , LIS()) ; // 求最大递增/上升子序列(如果为最大非降子序列,只需把上面的注释部分给与替换)
} return ;
}

hdu 1257 一共要多少套拦截系统 (LIS)的更多相关文章

  1. HDU1257:最少拦截系统(LIS)

    Problem Description 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高 ...

  2. HDU 1257 最少拦截系统(Dilworth定理+LIS)

    最少拦截系统 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Sub ...

  3. HDU 1257 最少拦截系统 (DP || 贪心)

    最少拦截系统 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Statu ...

  4. (hdu)1257 最少拦截系统

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1257 Problem Description 某国为了防御敌国的导弹袭击,发展出一种导弹拦 ...

  5. (最长不降子序列)最少拦截系统 -- hdu -- 1257

    http://acm.hdu.edu.cn/showproblem.php?pid=1257 最少拦截系统 Time Limit: 2000/1000 MS (Java/Others)    Memo ...

  6. HDU 1257 最少拦截系统(贪心 or LIS)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1257 最少拦截系统 Time Limit: 2000/1000 MS (Java/Others)   ...

  7. hdu dp 1257 最小拦截系统

    最少拦截系统 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Statu ...

  8. hdu 1257 最少拦截系统【贪心 || DP——LIS】

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=1257 http://acm.hust.edu.cn/vjudge/contest/view.action ...

  9. HDU 1257——最少拦截系统——————【LIS变型题】

    最少拦截系统 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Statu ...

随机推荐

  1. idea 插件的使用 进阶篇(个人收集使用中的)

    idea 插件的使用 进阶篇(个人收集使用中的) 恭喜你,如果你已经看到这篇文章,证明在idear使用上已经初有小成!那么就要向着大神进发了! 下边就是大神之路! 插件的设置 在 IntelliJ I ...

  2. 013、Dockerfile构建镜像(2019-01-02 周三)

    参考https://www.cnblogs.com/CloudMan6/p/6830067.html   Dockerfile构建镜像过程分析   root@docker-lab:~/111# ls  ...

  3. dijkstra补充

    dijkstra主要写法: priority_queue<pair<int,int> >q; //大根堆 //dis第一维为dis的相反数 void dijkstra(){ m ...

  4. C# 反射实例

    1.接口 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ...

  5. assistant文档

    资料  https://blog.csdn.net/La_vie_est_belle/article/details/82662937 contents  内容 signals    信号 Detai ...

  6. 2017CCPC秦皇岛 E题String of CCPC&&ZOJ3985【模拟】

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3985 题意: 给定一个字符串,由c和p组成,可以添加c或者p. 串中出现一 ...

  7. MyBatis学习-入门

    eclipse + jdk 1.8 + mybatis 1.数据库准备 安装mysql数据库,建立数据库test,在test库下建立测试的表 CREATE TABLE `t_user` ( `id` ...

  8. DBeaver入门

    1 安装好连接好数据库,查询操作 注意黄色字体1 2 3 4 执行sql操作

  9. Servlet.service() for servlet jsp threw exception

    报错信息如下: org.apache.catalina.core.ApplicationDispatcher invoke 严重: Servlet.service() for servlet jsp ...

  10. 2017-2018-2 20155303『网络对抗技术』Exp7:网络欺诈防范

    2017-2018-2 『网络对抗技术』Exp7:网络欺诈防范 --------CONTENTS-------- 一.原理与实践说明 1.实践目标 2.实践内容概述 3.基础问题回答 二.实践过程记录 ...