Interceptor missiles
-
Describe
-
A country has developed a missile interception system to defend against enemy missile attacks. But the missile interception system has a flaw: although its first shells can reach any height, each shot cannot be higher than the height of the previous one. One day, the radar caught the enemy missiles to attack. Since the system is still in the trial phase, it is possible to intercept all missiles by using only one set of systems.
-
-
Input
-
-
number of input test data groups in the first row N (1<=n<=10)
The next line is to enter the number of missile m (1<=m<=20) for this set of test data.
The next line is to enter the height of the missile in turn, and all the height values are positive integers greater than 0.
-
-
Output
-
-
outputs the maximum number of missiles to intercept
-
-
Sample input
-
-
28389 207 155 300 299 170 158 65388 34 65
-
-
Sample output
-
62
1#include <cstdio>2#include <algorithm>3#include <cstring>4 using namespacestd;5 6 intMain ()7 {8 //freopen ("In.txt", "R", stdin);9 intp[ +];Ten intdp[ +]; One inti,j,n,t; Ascanf"%d",&t); - while(t--) - { thescanf"%d",&n); -Memset (DP,0,sizeof(DP)); - intans=0; - for(i=0; i<n;i++) +scanf"%d",&p[i]); - for(i=0; i<n;i++) + { Adp[i]=1; at for(j=0; j<i;j++) - if(p[j]>P[i]) -Dp[i]=max (dp[i],dp[j]+1); -ans=Max (ans,dp[i]); - } -printf"%d\n", ans); in } -}
NYOJ 79 Interceptor missiles