最少拦截系统

Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

Appoint description: 
System Crawler  (2015-09-07)

Description

某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天,雷达捕捉到敌国的导弹来袭.由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹. 
怎么办呢?多搞几套系统呗!你说说倒蛮容易,成本呢?成本是个大问题啊.所以俺就到这里来求救了,请帮助计算一下最少需要多少套拦截系统. 
 

Input

输入若干组数据.每组数据包括:导弹总个数(正整数),导弹依此飞来的高度(雷达给出的高度数据是不大于30000的正整数,用空格分隔) 
 

Output

对应每组数据输出拦截所有导弹最少要配备多少套这种导弹拦截系统. 
 

Sample Input

8 389 207 155 300 299 170 158 65
 

Sample Output

2
 
 
 #include <iostream>
#include <cstdio>
#include <string>
#include <queue>
#include <vector>
#include <map>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <climits>
using namespace std; const int INF = 0x7fffffff;
vector<int> DP; int main(void)
{
int n,box; while(scanf("%d",&n) != EOF)
{
DP.clear();
while(n --)
{
scanf("%d",&box);
int loc = ;
int min = INF;
for(int i = ;i < DP.size();i ++)
if(DP[i] - box >= && DP[i] - box < min)
{
min = DP[i] - box;
loc = i;
}
if(min == INF)
DP.push_back(box);
else
DP[loc] = box;
}
printf("%d\n",DP.size()); } return ;
}
 

怒刷DP之 HDU 1257的更多相关文章

  1. 怒刷DP之 HDU 1160

    FatMouse's Speed Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Su ...

  2. 怒刷DP之 HDU 1260

    Tickets Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Stat ...

  3. 怒刷DP之 HDU 1176

    免费馅饼 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status  ...

  4. 怒刷DP之 HDU 1087

    Super Jumping! Jumping! Jumping! Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64 ...

  5. 怒刷DP之 HDU 1114

    Piggy-Bank Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit S ...

  6. 怒刷DP之 HDU 1069

    Monkey and Banana Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  7. 怒刷DP之 HDU 1024

    Max Sum Plus Plus Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  8. 怒刷DP之 HDU 1029

    Ignatius and the Princess IV Time Limit:1000MS     Memory Limit:32767KB     64bit IO Format:%I64d &a ...

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

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

随机推荐

  1. Oracle中TO_DATE格式

    转自:http://www.cnblogs.com/ajian/archive/2009/03/25/1421063.html TO_DATE格式(以时间:2007-11-02   13:45:25为 ...

  2. ags js下载地址

    https://developers.arcgis.com/en/downloads/ 备用

  3. Java程序内存分析:使用mat工具分析内存占用

    国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...

  4. insertAfter()

    <div id="b">bbbbbbbbb</div> <div>dddddd</div> JavaScript window.on ...

  5. myeclipse 10 载入新的项目报错Cannot return from outside a function or method

    myeclipse 10 载入新的项目报错Cannot return from outside a function or method 解决方法: 方法一: window -->prefere ...

  6. 把自定义类实例存储到LSO

    使用flash.net.registerClassAlias( )方法保留类型信息并把类实例添加到共享对象的data属性上. LSOs 使用特殊的二进制格式,Action Message Format ...

  7. windows下安装,配置gcc编译器

    在Windows下使用gcc编译器: 1.首先介绍下MinGW MinGW是指仅仅用自由软件来生成纯粹的Win32可运行文件的编译环境,它是Minimalist GNU on Windows的略称. ...

  8. Codeforces Round #313 (Div. 1) B. Equivalent Strings DFS暴力

    B. Equivalent Strings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559 ...

  9. .net处理JSON简明教程

    .net处理JSON简明教程 Json.Net是.net中的一种流行的高性能的JSON框架. 特点 灵活的JSON序列化转化.net对象为JSON字符串.和把JSON字符串转换为.net对象. 手动读 ...

  10. [Node.js] Broswerify -- 1

    Browserify is a tool that brings node.js style development to the browser. The thing you can see on ...