• HDOJ1257 最少拦截系统[DP入门]


    最少拦截系统

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
    Total Submission(s): 8593    Accepted Submission(s): 3332


    Problem Description
    某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天,雷达捕捉到敌国的导弹来袭.由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹.
    怎么办呢?多搞几套系统呗!你说说倒蛮容易,成本呢?成本是个大问题啊.所以俺就到这里来求救了,请帮助计算一下最少需要多少套拦截系统.
     
    Input
    输入若干组数据.每组数据包括:导弹总个数(正整数),导弹依此飞来的高度(雷达给出的高度数据是不大于30000的正整数,用空格分隔)
     
    Output
    对应每组数据输出拦截所有导弹最少要配备多少套这种导弹拦截系统.
     
    Sample Input
    8 389 207 155 300 299 170 158 65
     
    Sample Output
    2
     
    Source
     
    Recommend
    JGShining
     
     
     
    code:
     1 #include<iostream>
     2 using namespace std;
     3 int main()
     4 {
     5     int n;
     6     int str[1001];
     7     while(cin>>n)
     8     {
     9         int i,j;
    10         for(i=0;i<n;i++)
    11             cin>>str[i];
    12         int count(0);
    13         j=n;
    14         int max;
    15         while(j)
    16         {
    17             count++;
    18             max=35000;
    19             for(i=0;i<n;i++)
    20             {
    21                 if(str[i]!=-1&&str[i]<=max)
    22                 {
    23                     j--;
    24                     max=str[i];
    25                     str[i]=-1;
    26                 }
    27             }
    28         }
    29         cout<<count<<endl;
    30     }
    31     return 0;
    32 }






                If you have any questions about this article, welcome to leave a message on the message board.



    Brad(Bowen) Xu
    E-Mail : maxxbw1992@gmail.com


  • 相关阅读:
    rsync
    2个网卡流量的变化
    服务器端FIN的条件
    The third column indicates whether subclasses of the class declared outside this package have access to the member.;
    Java反序列化与远程代码执行

    address sizes : 46 bits physical, 48 bits virtual
    intptr_t、uintptr_t数据类型的解析
    Why should we typedef a struct so often in C?
    源码 502 回溯
  • 原文地址:https://www.cnblogs.com/XBWer/p/2593155.html
Copyright © 2020-2023  润新知