HDU 1257 Minimum interception system

Source: Internet
Author: User
Tags radar

Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=1257

Minimum interception system

Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 28771 Accepted Submission (s): 11328


Problem description A missile interception system developed by a country to defend against enemy missile attacks. But there is a flaw in this missile interception system: Although its first shells can reach any height, each shot cannot exceed the height of the previous one. Someday, The radar captures the enemy's missiles. Since the system is still in trial, there is only one set of systems that may not intercept all missiles.
What do we do? How many systems do you have? It's easy to say it. Cost is a big problem. So I came here to call for help, please figure out how many sets of interception systems you need at least.

Input enters several sets of data. Each group of data includes: Total number of missiles (positive integers), the height at which missiles fly (radar-given height data is a positive integer not greater than 30000, separated by a space)

Output corresponds to each set of data outputs to intercept all missiles with a minimum of how many sets of such missile interception systems.

Sample INPUT8 389 207 155 300 299 170 158 65

Sample Output2

SOURCE Zhejiang University of Technology The fourth session of college students Program design contest Greed:
#include <iostream>#include<cstdio>#include<cstring>#include<cstdlib>#include<algorithm>using namespacestd;Const intOO =1e9;intdp[100005];inta[100005];intMain () {intN;  while(~SCANF ("%d",&N)) { for(intI=1; i<=n; i++) {scanf ("%d", &A[i]); }        intx = a[1]; intAns =1; dp[1] = a[1];  for(intI=1; i<=n; i++)        {            intFlag =0; intMin =Oo; intT;  for(intj=1; j<=ans;j++)            {                if(Dp[j]>=a[i] && min>dp[j]-A[i]) {Min= dp[j]-A[i]; T=J; Flag=1; }            }            if(flag) {Dp[t]=A[i]; }            Else{dp[++ans] =A[i]; }} printf ("%d\n", ans); }    return 0;}

HDU 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.