• 最少拦截系统


    先吐槽一句!九度关了!!!!!!!!我的账号密码竟然不对了。。。。

    Description

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

    Input

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

    Output

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

    Sample Input

    8 389 207 155 300 299 170 158 65
     

    Sample Output

    2

    求最长不降序列

    //Asimple
    #include <iostream>
    #include <sstream>
    #include <algorithm>
    #include <cstring>
    #include <cstdio>
    #include <vector>
    #include <cctype>
    #include <cstdlib>
    #include <stack>
    #include <cmath>
    #include <set>
    #include <map>
    #include <string>
    #include <queue>
    #include <limits.h>
    #include <time.h>
    #define INF 0x7fffffff
    #define mod 123456
    #define swap(a, b, t) t = a, a = b, b = t
    using namespace std;
    const int maxn = 1001;
    int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
    typedef long long ll;
    ll n, m, num, T;
    //char str[maxn];
    //string s[maxn], s1, s2;
    ll a[maxn];
    
    int main(){
        while( cin >> n ){
            int Max = 0;
            int cnt = 0;
            for(int i=0; i<n; i++) {
                cin >> a[i];
            }
            while( true ) {
                bool f = false;
                int Max = 30000+1;
                for(int i=0; i<n; i++) {
                    if( a[i] > 0 && a[i]<=Max) {
                        Max = a[i];
                        a[i] = -1;
                        f = true;
                    }
                }
                if( f ) cnt ++ ;
                else break;
            }
            cout << cnt << endl;
        }
        return 0;
    }
    低调做人,高调做事。
  • 相关阅读:
    Caused by: java.lang.ClassNotFoundException: org.apache.http.message.TokenParser
    Uncaught TypeError: (intermediate value)(intermediate value)(intermediate value)(intermediate value)...is not a function
    Spring学习一(依赖注入/Bean/注解等)
    SpringMVC学习五(resultful风格/异常处理/注解)
    SpringMVC学习四(文件上传/拦截器)
    SpringMVC学习三(静态资源/AJAX功能/乱码问题)
    springboot整合websocket
    springboot整合成c3p0
    Dubbo相关
    Cestos秒装jdk
  • 原文地址:https://www.cnblogs.com/Asimple/p/6067566.html
Copyright © 2020-2023  润新知