Least interception system (hangdian 1257) (DP)

Source: Internet
Author: User
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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.