Time: 2016-03-11?16:52:26? Friday

Source: Internet
Author: User
Tags cmath

  • Time: 2016-03-11-16:52:26
  • Title Number: POJ 1887 testing the CATCHER
  • The main idea: a missile interception system that can intercept all missiles with a high altitude of less than the previous missile (the first missile will intercept), give some of the missiles, and ask how many missiles can be intercepted.
  • Input:
      • Several sets of data, each set of data ending with-1, if a set of data begins with 1, which represents the end of the input
  • Output:
      • Maximum number of intercepted missiles, at least 1 lines behind each set of data.
  • Analysis:
      • Given a sequence, each interceptor missile is less than or equal to the previous missile,
      • The title translates to, given a column number, the maximum non-ascending sequence
  • Monte, the number of missiles did not set a ceiling, but got a 1W max, water over ....
  • There is a blank line between each set of data!!!


#include <vector> #include <list> #include <map> #include <set> #include <deque> #include <queue> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <cctype> #include <string> #include <cstring> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> using namespace std; typedef Long long LL; #define The CLR(x, y) memset ((×), (y),sizeof((x))) #define for (x, Y, z) for ( int.) = (y);(x) < (*); + + (x)) #define FORD( x, Y, z) for(int.) = (y);(x) >= (z);--(x)) #define FOR2( x , Y, z) int. For((x) = (y);(x) < (z); + + (x)) #define FORD2( x , Y, z) int. For((x) = (y);(x) >= (z);--(x))



const int maxn = 10000; int DP[MAXN],A[MAXN]; int Main () { //freopen ("In.txt", "R", stdin); //freopen ("OUT.txt", "w", stdout); int cntcase = 0; while (~scanf ("%d", a) && ~a[0]) { int n = 1; CLR(dp,0); while (~scanf ("%d", A + N) && ~a[n]) ++n; CLR(dp,0);For (i,0,n) {Dp[i] = 1;For (j,0,i) { if(A[i] <= a[j]) {Dp[i] = max (Dp[i],dp[j] + 1);                                }                        }                } int ans = 0;For (i,0,n) {ans = max (Dp[i], ans);                }printf ("Test #%d:\n maximum possible interceptions:%d\n\n", ++cntcase,ans);         } return 0;}


From for notes (Wiz)

Time: 2016-03-11?16:52:26? Friday

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.