Minimum interception system
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 29960 Accepted Submission (s): 11754
problem DescriptionA missile interception system has been developed by a country to defend against enemy missile attacks. But there is a flaw in the 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.
Inputenter several sets of data. Each group of data includes: Total number of missiles (positive integers), the height at which the missiles are flown (radar-given height data is a positive integer not greater than 30000, separated by a space)
Outputcorresponding to each set of data output intercept all missiles with a minimum of how many sets of this missile interception system.
Sample Input8 389 207 155 299 158
Sample Output2
SourceThe Fourth annual college student Program Design Competition of Zhejiang University of Technology
recommendjgshiningMany of the ideas on the Internet are overlooked.
1#include <cstdio>2#include <algorithm>3 using namespacestd;4 5 Const intmax=100000;6 Const intinf=0x7ffffff;7 intB[max];8 intMain ()9 {Ten intN,count,num; One BOOLcatchsuc; A while(SCANF ("%d", &n) = =1) - { -Count=0; the for(intI=0; i<n;i++) - { -scanf"%d",&num); -Catchsuc=false; + intpos,temp=INF; - for(intj=0; j<count;j++) + { A if(num<=b[j]&&temp>B[j]) at { -Catchsuc=true; -temp=B[j]; -pos=J; - } - } in if(CATCHSUC) - { tob[pos]=num; + } - Else the { *b[count]=num; $count++;Panax Notoginseng } - } theprintf"%d\n", count); + } A}
HDU 1257 Minimum interception system