拦截导弹
来源:互联网 发布:淘宝买家秀活动规则 编辑:程序博客网 时间:2024/06/08 07:12
#include<stdio.h>#include<string.h>int dp[1010],a[1010];int main(){ int t,n; scanf("%d",&t); while(t--) { scanf("%d",&n); memset(dp,0,sizeof(dp)); int max,max2,i,j; for(i=0;i<n;i++) scanf("%d",&a[i]); max2=0; dp[0]=1; for(i=1;i<n;i++)//默认从第二位开始,dp[0]已经等于1 { max=1; for(j=0;j<=i-1;j++) { if(a[i]<a[j]&&dp[j]+1>max)//当前导弹的高度不能高于前边的导弹 max=dp[j]+1;//记录最大拦截数 } dp[i]=max;//i与它之前的数组合,所能组成的最长的递减序列长度 if(max2<max) max2=max;//max2来记录dp中的最大数,也就是最大拦截数 } printf("%d\n",max2); } return 0;}
阅读全文
0 0
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 导弹拦截
- 导弹拦截
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 拦截导弹
- 2675 3-6 静态数据成员与静态成员函数
- AsyncTask 工具类
- Bs总结
- HTTP通信的概念
- 分布式事务
- 拦截导弹
- 半年-足以改变一个人
- GSON生成与解析JSON数据
- Oracle 11g不能导出空表的三种实用解决方法
- Java多线程-- 公平锁(一)
- CSDN下载积分攻略
- python 3.5: TypeError: a bytes-like object is required, not 'str' when writing to a file
- 电路实验
- 2676 3-7 类的友元函数的应用