http://poj.org/problem?id=1887
题目很基础,就是求 最长减子数列
dp[i]=max{ max{ dp[j]+1 (arr[i]<arr[j] ; 1<=j<i )} , 1 }
#include<iostream>
using namespace std;
const int MAX = 100000;
int index;
int dp[MAX];
int arr[MAX];
int main(){
int cin1;
int t=1;
while(scanf("%d",&cin1)&&cin1!=-1){
index=1;
arr[index++]=cin1;
while(scanf("%d",&cin1)&&cin1!=-1){
arr[index++] = cin1;
}
index--;//arr[1]--arr[index]
dp[1]=1;
int max=1;
for(int i=2;i<=index;i++){
dp[i]=1;
for(int j=1;j<i;j++){
if(arr[i]<arr[j]&&dp[i]<dp[j]+1)
dp[i] = dp[j]+1;
}
if(dp[i]>max)max=dp[i];
}
cout<<"Test #"<<t++<<":"<<endl<<" maximum possible interceptions: "<<max<<endl<<endl;
}
return 0;
}