怎麼辦呢?多搞幾套系統唄!你說說倒蠻容易,成本呢?成本是個大問題啊.所以俺就到這裏來求救了,請幫助計算一下最少需要多少套攔截系統.
Output對應每組數據輸出攔截所有導彈最少要配備多少套這種導彈攔截系統.
Sample Input
8 389 207 155 300 299 170 158 65Sample Output
2
PS:很驚喜的一道題,剛學過LCS,做練習時看見這道題,自己用LCS的思想改了一下寫出來了,最後知道原來這是LIS。
#include<cstdio>
#include<cstring>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int a[1000+5];
int dp[1000+5];
int main()
{
int n,m,i,j,k;
while(scanf("%d",&n) != EOF)
{
for(i=0;i<n;i++)
scanf("%d",&a[i]);
int ans=1;
for(i=0;i<n;i++)
{
dp[i]=1;
for(j=0;j<i;j++)
{
if(a[i]>a[j])
{
dp[i]=max(dp[i],dp[j]+1);
}
ans=max(dp[i],ans);
}
}
printf ("%d\n",ans);
}
return 0;
}