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

求一套系统能防御的最大导弹数: 反向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. 编写优秀jQuery插件技巧

    1. 把你的代码全部放在闭包里面 这是我用的最多的一条.但是有时候在闭包外面的方法会不能调用. 不过你的插件的代码只为你自己的插件服务,所以不存在这个问题,你可以把所有的代码都放在闭包里面. 而方法可 ...

  2. "ls: cannot access sys/class/ieee80211: No such file or directory" .

    1- Do update and upgrade as always. apt-get update && apt-get upgrade && apt-get dis ...

  3. SQL——Hibernate SQL增删改查

    1.查询list数据 实例:user login public String userLogin(){ Session session = HibernateSessionFactory.getSes ...

  4. luogu P1593 因子和

    不要吐槽博主总做这些数论氵题 首先我们看到这种因数问题,果断质因数分解 所以当前数\(a=p_1^{k_1}*p_2^{k_2}...*p_m^{k_m}\) 可得\(a^b=p_1^{k_1*b}* ...

  5. tcp的连接断开

    tcp的断开连接是需要主机完成四次挥手的过程的,并不是断网了就表示断开连接了.假如双方已经建立起了连接,突然一方断网(比如突然停电,或者网线突然被拔了),对于另一方来讲他并不会知道这个情况,他依然认为 ...

  6. Database学习 - mysql 连接数据库 库操作

    连接数据库 语法格式: mysql -h 服务器IP -P 端口号 -u用户名 -p密码 --prompt 命令提示符 --delimiter 指定分隔符 示例: mysql -h 127.0.0.1 ...

  7. adb不识别设备(手机)的若干情形及解决方法

    1.执行adb root  提示adb: unable to connect for root: no devices/emulators found:执行adb devices ,List下无设备 ...

  8. 2017-2018-2 20155303『网络对抗技术』Exp5:MSF基础应用

    2017-2018-2 20155303『网络对抗技术』Exp5:MSF基础应用 --------CONTENTS-------- 一.原理与实践说明 1.实践内容 2.预备知识 3.基础问题 二.实 ...

  9. 20165230田坤烨《网络对抗》Exp1 PC平台逆向破解

    实践目标 本次实践的对象是一个名为pwn1的linux可执行文件. 该程序正常执行流程是:main调用foo函数,foo函数会简单回显任何用户输入的字符串. 该程序同时包含另一个代码片段,getShe ...

  10. Docker镜像原理

    ⒈是什么? 镜像是一种轻量级.可执行的独立软件包,用来打包软件运行环境和基于运行环境开发的软件,它包含运行某个软件所需的所有内容,包括代码.运行时.库.环境变量以及配置文件等. 引用 UnionFs( ...