HDOJ 1257 Minimum interception system

Source: Internet
Author: User
Tags radar



/* Minimum interception system
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 25347 Accepted Submission (s): 9959
Problem Description
A country has developed a missile interception system to defend against enemy missile attacks. But there is a flaw in this missile-blocking system:
Although its first shells can reach any height, each projectile cannot exceed the height of the previous one.
One day, the radar caught the enemy's missiles. Since the system is still in the trial phase, there is only one set of systems,
It is therefore possible that all missiles cannot be intercepted.
What do we do? How many systems do you have? It's easy to say, cost? Cost is a big problem.
So I came here to ask for help, please figure out how many sets of interception system you need at least.
Input
Enter several sets of data. Each group of data includes: Total number of missiles (positive integers), the height at which the missiles fly
(Radar-given height data is a positive integer not greater than 30000, separated by a space)

Output

corresponding to each set of data output intercept all missiles with a minimum of how many sets of this missile interception system.
Sample Input
8 389 207 155 300 299 170 158 65
Sample Output
2*/

<span style= "FONT-SIZE:18PX;" > #include <stdio.h> #include <string.h>int a[1000008],b[1000008];int main () {int n,i,k,j; while (scanf (" %d ", &n) ==1) {  k=0;  scanf ("%d", &a[0]);  B[K]=A[0];  for (i=1;i<n;i++)  {   scanf ("%d", &a[i]);   for (j=0;j<=k;j++)    if (B[j]>a[i])    {     b[j]=a[i];     break;    }   if (j>k)   {    b[++k]=a[i];   }  }  printf ("%d\n", k+1); } return 0;}  </span>


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

HDOJ 1257 Minimum interception system

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.