I-Minimum interception system HDU 1257

Source: Internet
Author: User
Tags radar


I-Minimum interception system
Time limit:1000ms Memory limit:32768kb 64bit IO format:%i64d &%i64u
Submit Status Practice HDU 1257

Description
A 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 artillery shells can reach any height, each shot cannot exceed the height of the previous pitch. One day, the radar caught the enemy's missiles. As the system is still in the trial phase, So there is only one set of systems, so it is possible not to 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
Enter 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)


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

The Intercept height is decremented, so it is the longest ascending subsequence.

 #include <bits/stdc++.h>using namespace Std;template<class t>inline T Read (t&x) {char C;    while ((C=getchar ()) <=32) if (c==eof) return 0;    BOOL Ok=false;    if (c== '-') Ok=true,c=getchar ();    for (x=0; c>32; C=getchar ()) x=x*10+c-' 0 ';    if (OK) x=-x; return 1;} Template<class t> inline T read_ (t&x,t&y) {return read (x) &&read (y);} Template<class t> inline T read__ (t&x,t&y,t&z) {return read (x) &&read (y) &&read (z);}    Template<class t> inline void Write (T x) {if (x<0) Putchar ('-'), x=-x;    if (x<10) putchar (x+ ' 0 '); else write (X/10), Putchar (x%10+ ' 0 ');}    Template<class t>inline void Writeln (T x) {write (x); Putchar (' \ n ');} -------ZCC IO template------const int MAXN=1E5+1000;CONST double inf=999999999; #define Lson (rt<<1), L,m#define Rson (rt<<1|1), M+1,r#define M ((l+r) >>1) #define for (i,t,n) for (int i= (t);i< (n); i++) typedef long Long LL; typedef double DB;TYPEDEF Pair<int,int> P; #define BUG printf ("---\ n"); #define MOD 100007int a[maxn];int dp[maxn];int main () {int n,e,f;        while (read (n)) {for (int i=0;i<n;i++) read (A[i]);        Fill (Dp,dp+n,inf);        for (int i=0;i<n;i++) {*lower_bound (Dp,dp+n,a[i]) =a[i];    } writeln (Lower_bound (Dp,dp+n,inf)-DP); } return 0;}

I-Minimum interception system HDU 1257

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.