拦截导弹 OpenJ_Bailian
来源:互联网 发布:武汉软件行业协会 编辑:程序博客网 时间:2024/06/03 15:46
某国为了防御敌国的导弹袭击,开发出一种导弹拦截系统。但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能高于前一发的高度。某天,雷达捕捉到敌国的导弹来袭,并观测到导弹依次飞来的高度,请计算这套系统最多能拦截多少导弹。拦截来袭导弹时,必须按来袭导弹袭击的时间顺序,不允许先拦截后面的导弹,再拦截前面的导弹。
第一行,输入雷达捕捉到的敌国导弹的数量k(k<=25),
第二行,输入k个正整数,表示k枚导弹的高度,按来袭导弹的袭击时间顺序给出,以空格分隔。
8300 207 155 300 299 170 158 65
6
// POWERED BY ZQQIAN IN 2017/3/5//简单题#include "iostream"#include"algorithm"using namespace std;int a[30] ;int num;int t(int n) {int m = 1;if (n==num-1){return 1;}for (int i = n+1; i < num; i++){if (a[i]<=a[n]){m = max(m, t(i) + 1);}}return m;}int main(){scanf("%d", &num);for (int i = 0; i < num; i++){scanf("%d", &a[i]);}int x=1;for (int i = 0; i < num; i++){x = max(x, t(i));}printf("%d", x); return 0;}
0 0
- 拦截导弹 OpenJ_Bailian
- 0809 OpenJ_bailian#2945 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 导弹拦截
- 导弹拦截
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 51nod 1116 K进制下的大数
- 1067. 试密码(20)
- Leetcode215. Kth Largest Element in an Array
- pat-a1071. Speech Patterns (25)
- CentOS下zookeeper集群搭建
- 拦截导弹 OpenJ_Bailian
- C++ 构造函数 和 函数对象
- 穷举法,实例5,四平方和
- POJ2481 Cows 树状数组
- the sixth day/小白来css了
- HMM模型与Vertibi算法
- 定位MySQL锁和事务问题的两大利器
- Android的.so文件你需要知道那些知识
- 算法