NYOJ-79 拦截导弹 AC 分类: NYOJ 2014-01-01 23:25 167人阅读 评论(0) 收藏


#include<stdio.h>
int main(){
	int num[1000]={0};
	
	int n,m,x,y;
	scanf("%d",&n);
	while(n--){
		int max=0;
		int sum[1000]={0};
		scanf("%d",&m);
		for(x=0;x<m;x++){
			scanf("%d",&num[x]);
		}
		for(x=m;x>=0;x--){
			for(y=x;y<=m-1;y++){
				if((num[y]<num[x])&&(sum[x]<=sum[y])){
					sum[x]=sum[y]+1;
				}
			}
			if(sum[x]>max)max=sum[x];
		}
		printf("%d\n",max+1);
	}
	return 0;
}

以前总是WA,今天重写了代码,终于AC了

版权声明:本文为博主原创文章,未经博主允许不得转载。

posted @ 2014-01-01 23:25  天I火  阅读(102)  评论(0)    收藏  举报