Minimum Interception System
Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)
Total submission (s): 19432 accepted submission (s): 7719
Problem description a country has developed a missile interception system to defend against missile attacks by the enemy. however, this missile interception system has a defect: although its first shell can reach any height, it cannot exceed the height of the previous one. one day, the radar captured the enemy's missiles. because the system is still in the trial phase, there is only one system, so it may not be able to intercept all missiles.
What should we do? How many more systems are involved! It's easy to talk about. What about the cost? The cost is a big problem, so I am here for help. Please help calculate the minimum number of interception systems required.
Input several groups of data. each set of data includes the total number of missiles (positive integers), and the height of missiles flying here (the height data given by the radar is a positive integer not greater than 30000, separated by spaces)
The output corresponds to the minimum number of missile interceptions required for each set of data output to intercept all missiles.
Sample Input
8 389 207 155 300 299 170 158 65
Sample output
2#include<stdio.h>#include<math.h>int a[30001],b[30001];int main(){ int n,i,j,k; while(scanf("%d",&n)!=EOF) { b[0]=0;k=0; for(i=0;i<n;i++) { scanf("%d",&a[i]); for(j=0;j<=k;j++) { if(a[i]<b[j]) { b[j]=a[i]; break; } else if(j==k) { k++; b[k]=a[i]; break; } } } printf("%d\n",k); } return 0;}
Least interception system (hangdian 1257) (DP)